Disabling right click context menu on a HTML Canvas?

前端 未结 6 1745
醉梦人生
醉梦人生 2021-02-05 00:45

Making a painting app using HTML5 and Canvas.

I think I want to have a similar system to applications like Paint and Photoshop where you can have a primary and secondary

6条回答
  •  梦毁少年i
    2021-02-05 01:16

    Try adding oncontextmenu="return false;" on the body tag. It should disable the context menu.

    If I believe this source : http://javascript.about.com/library/blnoright.htm which is google's first result to the query "javascript disable right click" that you should have tried.

    Edit :

    • about canvas I don't know the element, but did you try calling stopPropagation() on the event element once your function ends ?
    • or the previous solution on the canvas tag instead of the body...

提交回复
热议问题