Disabling right click on images using jquery

前端 未结 9 2142

I want to know how to disable right click on images using jQuery.

I know only this:



        
9条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 20:39

    what is your purpose of disabling the right click. problem with any technique is that there is always a way to go around them. the console for firefox (firebug) and chrome allow for unbinding of that event. or if you want the image to be protected one could always just take a look at their temporary cache for the images.

    If you want to create your own contextual menu the preventDefault is fine. Just pick your battles here. not even a big JavaScript library like tnyMCE works on all browsers... and that is not because it's not possible ;-).

    $(document).bind("contextmenu",function(e){
      e.preventDefault()
    });
    

    Personally I'm more in for an open internet. Native browser behavior should not be hindered by the pages interactions. I am sure that other ways can be found to interact that are not the right click.

提交回复
热议问题