mikebyrne Posted October 10, 2011 Share Posted October 10, 2011 I've implemented the following script into my page to disable users from right clicking <script language=JavaScript> <!-- //Disable right mouse click Script //By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive //For full source code, visit http://www.dynamicdrive.com var message="Richt Click Disabled!"; /////////////////////////////////// function clickIE4(){ if (event.button==2){ alert(message); return false; } } function clickNS4(e){ if (document.layers||document.getElementById&&!document.all){ if (e.which==2||e.which==3){ alert(message); return false; } } } if (document.layers){ document.captureEvents(Event.MOUSEDOWN); document.onmousedown=clickNS4; } else if (document.all&&!document.getElementById){ document.onmousedown=clickIE4; } document.oncontextmenu=new Function("alert(message);return false") // --> </script> The problem is when you right click the first time the message appears and seems to work correctly. If you right click again, the errorbox appears "Right Click Disabled" and underneath it "Prevent this page from creating additional dialogues" with a checkbox. All the user needs to do it tick the checkbox and they are able to right click. Is there a way I can stop this happening?? Quote Link to comment https://forums.phpfreaks.com/topic/248793-disable-right-click-on-works-once/ Share on other sites More sharing options...
trq Posted October 10, 2011 Share Posted October 10, 2011 Why the hell would you even bother trying to annoy your visitors like this? Quote Link to comment https://forums.phpfreaks.com/topic/248793-disable-right-click-on-works-once/#findComment-1277685 Share on other sites More sharing options...
mikebyrne Posted October 10, 2011 Author Share Posted October 10, 2011 It was more to stop people looking at the page source Quote Link to comment https://forums.phpfreaks.com/topic/248793-disable-right-click-on-works-once/#findComment-1277697 Share on other sites More sharing options...
joe92 Posted October 10, 2011 Share Posted October 10, 2011 What about Inspect Element / firebug? They can be launched without having to right click and show your source plus some. Disabling right click won't achieve much. Quote Link to comment https://forums.phpfreaks.com/topic/248793-disable-right-click-on-works-once/#findComment-1277787 Share on other sites More sharing options...
mikebyrne Posted October 10, 2011 Author Share Posted October 10, 2011 Good point. I've no top secret info to protect or anything so should I just not bother? Quote Link to comment https://forums.phpfreaks.com/topic/248793-disable-right-click-on-works-once/#findComment-1277790 Share on other sites More sharing options...
joe92 Posted October 10, 2011 Share Posted October 10, 2011 I wouldn't bother wasting any time on it if I were you. To many ways to very easily view the source in an alternative way. Plus you would also be disabling features such as copy and paste and bookmarking the page (and you would definitely want the latter!). Quote Link to comment https://forums.phpfreaks.com/topic/248793-disable-right-click-on-works-once/#findComment-1277805 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.