Tech Sharing

Tech Sharing

Advertisement

Javascript to disable right cilck on web site

By on August 18, 2011

Just come across with my company SQA team where they request us to do the disable right click features on our front end web site. The initial javascript which exists in our script only work with Microsoft Internet Explorer but not Firefox.

So Google around and found the following javascript which working for both the browser (Firefox and Internet Explorer are the major browser use by our visitor)

Just include this script in our top of the page which you wish to disable the right click function.

<script type="text/javascript">

function md(e)
{
  try { if (event.button==2||event.button==3) return false; }
  catch (e) { if (e.which == 3) return false; }
}
document.oncontextmenu = function() { return false; }
document.ondragstart   = function() { return false; }
document.onmousedown   = md;

</script>

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Comments

No Responses to “Javascript to disable right cilck on web site”

Write a Comment

Captcha * Time limit is exhausted. Please reload CAPTCHA.

%d bloggers like this: