admin管理员组文章数量:1287281
I have a canvas and I display an image inside it. I have attached a jquery event to it, like this:
$("#mycanvas").mousedown(function(e) {
//Do something
e.preventDefault();
e.stopPropagation();
});
I would expect this code to do my operations and to prevent default browser behavior. The former is fulfilled, however, the latter, namely, default behavior prevention does not happen. The event runs though. I wonder how could I prevent showing that menu you can see on the image upon right-click:
I have a canvas and I display an image inside it. I have attached a jquery event to it, like this:
$("#mycanvas").mousedown(function(e) {
//Do something
e.preventDefault();
e.stopPropagation();
});
I would expect this code to do my operations and to prevent default browser behavior. The former is fulfilled, however, the latter, namely, default behavior prevention does not happen. The event runs though. I wonder how could I prevent showing that menu you can see on the image upon right-click:
Share Improve this question asked Jul 28, 2016 at 8:27 Lajos ArpadLajos Arpad 77k40 gold badges117 silver badges222 bronze badges 3- 2 Be aware that while preventing right click will stop the context menu appearing, I can still see the URL to the image and download it through the DOM viewer/dev tools. The old adage applies - if it's viewable online, anyone can take it. – Rory McCrossan Commented Jul 28, 2016 at 8:30
- @RoryMcCrossan, that's ok, I just want the user not to see that menu, everything else is nice. – Lajos Arpad Commented Jul 28, 2016 at 8:32
- Possible duplicate? stackoverflow./questions/4920221/… – Whothehellisthat Commented Jul 28, 2016 at 8:36
1 Answer
Reset to default 13You can use contextmenu:
$("#mycanvas").contextmenu(function(e) {
//Do something
e.preventDefault();
e.stopPropagation();
});
本文标签: javascriptHow to prevent default right click on canvas containing imageStack Overflow
版权声明:本文标题:javascript - How to prevent default right click on canvas containing image - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741213793a2359651.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论