With Below Script we can easily disable the right mouse click using JavaScript.
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script language=JavaScript> //Disable right mouse click Script /* * The document.all collection is specific to Internet Explorer. The document.layers collection was specific to Netscape. Neither is in the standards. Today we use document.getElementById instead. https://developer.mozilla.org/en-US/docs/Mozilla_Web_Developer_FAQ#JavaScript_doesn.E2.80.99t_work.21_Why.3F */ var message="Function Disabled!"; function clickIE4(){ if (event.button==2){ alert(message); return false; } } function clickNS4(e){ if (document.layers||document.getElementById&&!document.all){ if (e.which==2||e.which==3){ alert(message); return false; } } } if (document.layers){ document.captureEvents(Event.MOUSEDOWN); document.onmousedown=clickNS4; } else if (document.all&&!document.getElementById){ document.onmousedown=clickIE4; } document.oncontextmenu=new Function("alert(message);return false") </script> </head> <body> <div id="layout"> <div id="product-options"> <select id="productlist"> <option value="1">Product A</option> <option value="10">Product B</option> <option value="20">Product C</option> <option value="1000">Product D</option> <option value="40">Product E</option> <option value="3">Product F</option> <option value="5">Product G</option> </select> </div> </div> <button type="button" onclick="myFunction()">Try it</button> <p id="demo"></p> </body> </html>
0 Comments