Here we mainly introduce two methods, one is to use JS to handle, and the other is set in the HTML attribute.
Method One: JS
1:
<script language= "javascript" >document.onmousedown=disableclick;status= "right click Disabled"; Function Disableclick (event) { if (event.button==2) { alert (status); return false; }} </script>
2:
Document.addeventlistener ("ContextMenu", function (e) { e.preventdefault ();}, False);
3: Using jquery
$ (document). On ({ "ContextMenu": function (e) { console.log ("ctx menu button:", E.which); Stop the context menu e.preventdefault (); }, "MouseDown": function (e) { console.log ("Normal mouse Down: ", E.which); }, " MouseUp ": function (e) { console.log (" Normal mouse Up: ", E.which);} );
Or:
$ (document). Ready (function () { Document.oncontextmenu = Document.body.oncontextmenu = function () {return false;} });
Method Two: HTML property settings
‘
<body oncontextmenu= "return false" >...</body>
Finally: Try not to do so unless special use.
Preference:http://stackoverflow.com/questions/737022/how-do-i-disable-right-click-on-my-web-page