Jump to content

Disable Right click on works once??


mikebyrne

Recommended Posts

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 ([email protected]) 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??

Link to comment
https://forums.phpfreaks.com/topic/248793-disable-right-click-on-works-once/
Share on other sites

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!).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.