Monday, August 23, 2010

Disable Right click in Page

<html>
<head>
<script type="text/javascript">
document.onmousedown=disable; //IE
message="Sorry no rightclick on this page.\nNow you cannot view my source\nand you cannot steal my images";
function disable(e)
{
if (e == null)
  { //IE disable
  e = window.event;
  if (e.button==2)
    {
    alert(message);
    return false;
    }
  }
document.onclick=ffdisable;  //FF
}
function ffdisable(e)
{
if (e.button==2)
  { //firefox disable
  e.preventDefault();
  e.stopPropagation();
  alert(message);
  return false;
  }
}
</script>
</head>

<body>
<p>Right-click on this page to trigger the event.</p>
<p>Note that this does not guarantee that someone won't view the page source or steal the images.</p>
</body>
</html>

No comments:

Post a Comment