Thursday, July 14, 2011

Disable Right Click -Asp.Net


<script language="JavaScript">
      // on right click appear this message
      var DisplayMsg="Right Click Disabled";
      //return message
      function clickBYIE()
      {
          if(document.all)
          {
              alert(DisplayMsg);
              return false;
          }
      }
      //return message
      function clickBYNS(e)
      {
          if (document.layers||(document.getElementById&&!document.all))
          {
              if (e.which==2||e.which==3)
              {
               alert(DisplayMsg);
               return false;
              }
          }
      }

     //set the function as per browser
      if (document.layers)
      {
          document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickBYNS;
      }
      else
      {
          document.onmouseup=clickBYNS;document.oncontextmenu=clickBYIE;
      }
      //disabled the right click on the browser
       document.oncontextmenu=new Function("return false")
  </script>

No comments:

Post a Comment

Ajax CalendarExtender displaying at wrong position in Chrome

< script type ="text/javascript" language ="javascript">     function onCalendarShown(sender, args)...