If i put that in <body onContextMenu="returnfalse"> it disabled the right click option in whole application .
But i need to that for a particular page. How can i?
you can put oncontextmenu="return false;" on a div also. so in perticuler page on which you want to disable it just add a div and put oncontextmenu="return false;" like
ssjGanesh
Participant
1928 Points
1352 Posts
disable right click option for particular page.
Feb 22, 2012 05:46 AM|LINK
I need to disable the right click option in a particular page only.
I have only one <form><body> in my master page.
If i put that in <body onContextMenu="return false"> it disabled the right click option in whole application .
But i need to that for a particular page. How can i?
Mark as answer,if it helped U!
prasadP
Contributor
5266 Points
771 Posts
Re: disable right click option for particular page.
Feb 22, 2012 05:54 AM|LINK
Hi Friend,
Try Adding follwoing in particular page -
<script type="text/javascript">
window.oncontextmenu = function () {
return false;
}
</script>
Check https://developer.mozilla.org/en/DOM/window.oncontextmenu
Blog
ItsSunny
Contributor
2163 Points
676 Posts
Re: disable right click option for particular page.
Feb 22, 2012 06:01 AM|LINK
include the following javascript code in ur content page to block right click
<script language="javascript" type="text/javascript"> var BM = 2; var BR = 3; function mouseDown(e) { try { if (event.button == BM || event.button == BR) { return false; } } catch (e) { if (e.which == BR) { return false; } } } document.oncontextmenu = function () { return false; } document.onmousedown = mouseDown; </script>Arun Sunny.
shivv
Participant
1566 Points
283 Posts
Re: disable right click option for particular page.
Feb 22, 2012 06:08 AM|LINK
you can put oncontextmenu="return false;" on a div also. so in perticuler page on which you want to disable it just add a div and put oncontextmenu="return false;" like
<div oncontextmenu="return false;">
// you page html code
</div>
ItsSunny
Contributor
2163 Points
676 Posts
Re: disable right click option for particular page.
Feb 22, 2012 06:10 AM|LINK
did it worked in IE ?
Arun Sunny.
Sum8
Contributor
4141 Points
931 Posts
Re: disable right click option for particular page.
Feb 22, 2012 06:28 AM|LINK
Try this:
<script language="JavaScript"> function right(e) { if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) // Validating the browser return false; else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) { alert("This is 'Right Click' Protected Screen"); // Alert Msg by User return false; } return true; } document.onmousedown=right; </script>Sumit Pathak
------------------
ThisPost = Helped == True ? "Mark As Answer" : "Elaborate your problem in more details"
dineshchaudh...
Member
326 Points
131 Posts
Re: disable right click option for particular page.
Feb 22, 2012 06:31 AM|LINK
Hi Prasad,
Thanx for ur information....it will be help me in future....
but it is not working in IE.....
Can u pls provide any soln for IE??
Thanks
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
prasadP
Contributor
5266 Points
771 Posts
Re: disable right click option for particular page.
Feb 22, 2012 07:14 AM|LINK
Hi,
<script type="text/javascript">
document.oncontextmenu = function () {
//alert('oncontextmenu');
return false;
}
</script>
This is working in both IE,FF as well as in Google Chrome.
Also check http://msdn.microsoft.com/en-us/library/ms536914(v=vs.85).aspx
and http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/oncontextmenuEX1.htm#
Blog