PDA

View Full Version : Right Click Disable ( Annoy/Close)



Elektra
07-24-2010, 10:28 PM
1) CODE TITLE:
Right Click Disable ( Annoy/Close)

2) AUTHOR NAME/NOTES:
Aimee Beery

3) DESCRIPTION:
This will give annoying messages to those who right click after last one webpage auto closes.

4) URL TO CODE:

or, ATTACHED BELOW (see #3 in guidelines below):



<script type="text/javascript">
<!--
var closeWin="1"; // Do you want to close window (1 for yes 0 for no)
var alertVis="1"; // Do you want to alert the visitor (1 for yes 0 for no)
var message="Right click disabled on images!"; // Your no right click message this line

/*
Disable right click script (Annoy-Close)
By Aimee Beery
*/

function detail(){
if(alertVis == "1") alert(message);
alert("You like to right click?")
alert("How about left clicking?")
alert("Left Click!")
alert("Left Click!")
alert("Left Click!")
alert("Left Click!")
alert("Left Click!")
alert("Left Click!")
alert("Left Click!")
alert("Left Click!")
alert("Left Click!")
alert("Left Click!")
alert("Left Click!")
alert("Left Click!")
if(closeWin == "1") self.close();
return false;
}
function IE() {
if (event.button == "2" || event.button == "3"){detail();}
}
function NS(e) {
if (document.layers || (document.getElementById && !document.all)){
if (e.which == "2" || e.which == "3"){ detail();}
}
}
document.onmousedown=IE;document.onmouseup=NS;document.oncontextmenu=new Function("return false");

//-->
</script>

jscheuer1
07-25-2010, 07:58 AM
Javascript cannot close a window that wasn't opened with javascript.

djr33
07-26-2010, 03:15 AM
This also shouldn't be done: it is not possible to fully prevent the user from right clicking (or at least it's not possible to prevent them from doing the same thing some other way, such as saving images or source code), and the only cases where this is an advantage to the user are pages where the right click has another function such as opening a menu. And in these cases, annoying the user is clearly not the intent.

Though dynamic drive has some scripts like this (but none so aggressive), the current direction of the site is moving away from that.