Monday, 5 December 2011

Disabling Right-Click on a web page


To protect your source code should not be copied either by using right click or by ctrl+c then use the bellow code in head tags

<head>
 <title>Untitled Page</title>
 <meta http-equiv="imagetoolbar" content="no" />
 <script type="text/javascript" language="javascript">
  var msg="Sorry, right-click has been disabled";
  function WhenIE() {if (document.all) {alert(msg);return false;}}
  function WhenNS(e) {if
   (document.layers||(document.getElementById&&!document.all)) {
    if (e.which==2||e.which==3) {alert(msg);return false;}}}
   if (document.layers)
    {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=WhenNS;}
   else{document.onmouseup=clickNS;document.oncontextmenu=WhenIE;}
    document.oncontextmenu=new Function("return false")
 </script>
 <script type="text/javascript" language="javascript">
 function disableselect(e){ return false }
 function reEnable(){ return true }
 document.onselectstart=new Function ("return false")
 if (window.sidebar){
  document.onmousedown=disableselect
  document.onclick=reEnable
 }
</script>
</head>

Tag: asp, Click, content, Disabling, dot, double, image, java script, net, protect, Right, save, secure, selection text, source code, web page

No comments:

Post a Comment

Parsing JSON w/ @ symbol in it

To read the json response like bellow @ concatenated with attribute                             '{ "@id": 1001, "@name&q...