<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Sample to Disable Right Click of Page</title> <script language="JavaScript" type="text/javascript"> //Message to display whenever right click on website var message = "Sorry, Right Click have been disabled."; function click(e) { if (document.all) { if (event.button == 2 || event.button == 3) { alert(message); return false; } } else { if (e.button == 2 || e.button == 3) { e.preventDefault(); e.stopPropagation(); alert(message); return false; } } } if (document.all) { document.onmousedown = click; } else { document.onclick = click; } </script> </head> <body> <form id="form1" runat="server"> <div> </div> </form> </body> </html> |
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|

Subscribe by RSS
Subscribe by Email
11 comments :
Thanks Again !!!
This code really works as charm for me.
hello! i need code to disable all the controls which able to copy the data in PDF file when opened in WEBSITE!!
PLZ.....MAKE it !!
Dear sir i m new to your website.Really very very usable and good.I like this site.
But sir i want know that one, whatever you have wrote for disabling right Click on a asp page, it works on IE only,
But i want to know what have to do for other Browser to disable rt clk.plz do the needfull.Thanks in adv.
thanking you very much
This is useful script by suresh.One more thing is,write this script in .js file and save it in solution explorer 'script' folder and call it from Master page.
How to disable file upload & file download options using c#.net
Thanks ...It is works
it's not working for me.... pls help
Thanks Suresh!!!
Its working fine.....
Not working at all on chrome...
your site is very helpful.. Thanks a lot.
Sir i am trying to block save page as option in the menu of FF & IE web browser so the images, script do not get downloaded when user click save page as html format... I hv disable the right click menu, but still users can access the sources page from the main menu..
Kindly give your suggestion/advice on it, how can i do it