Jyoti Vinay Pandey Jyoti Vinay Pandey - 9 months ago 46
Javascript Question

How do I disable right click on my web page?

Can I disable right click on my web page without using Javascript? I ask this because most browsers allow user to disable Javascript.

If not, how do I use JavaScript to disable right click?

Answer Source

You can do so with Javascript and/or an HTML attribute (which is really a Javascript event handler anyway) as described here:

<script language="javascript">
status="Right Click Disabled";
function disableclick(event)
     return false;    


<body oncontextmenu="return false">

That being said: DON'T DO IT.

Why? Because it achieves nothing other than annoying users. Also many browsers have a security option to disallow disabling of the right click (context) menu anyway.

Not sure why you'd want to. If it's out of some misplaced belief that you can protect your source code or images that way, think again: you can't.