/ Published in: JavaScript
This snippet code allows you to prevent the viewer from being able to right-click on your page. This can discourage the average user from borrow images or code from your site.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript"> function f1() { if(document.all) { return false; } } function f2(e) { if(document.layers || (document.getElementById && document.all)) { if(e.which==2 || e.which==3) { return false; } } } if(document.layers) { document.captureEvents(Event.MOUSEDOWN); document.onmousedown = f1; } else { document.onmouseup = f2; document.oncontextmenu = f1; } document.oncontextmenu = new function("return false"); </script>
URL: http://www.apphp.com/index.php?snippet=javascript-blocking-right-click