Disable Right Click - Php

How to disable right click option using php code?

Snippet Code


  
Rate this page :
  [ 0 votes]

This following php code can be used to disable mouse right click option. Here, "disable_right_click()" function is used to disable right click in the webpage.

<?php function disable_right_click() { echo ' <script type="text/javascript"> var isNS = (navigator.appName == "Netscape") ? 1 : 0; if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP); function mischandler(){ return false; } function mousehandler(e){ var myevent = (isNS) ? e : event; var eventbutton = (isNS) ? myevent.which : myevent.button; if((eventbutton==2)||(eventbutton==3)) return false; } document.oncontextmenu = mischandler; document.onmousedown = mousehandler; document.onmouseup = mousehandler; </script>'; } disable_right_click(); echo "<h2>Disable Right Click</h2>"; ?>

Tags


Ask Questions

Ask Question