Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Right-mouse disable without alert

Status
Not open for further replies.

Quasibobo

Programmer
Oct 11, 2001
168
NL
Hi,

What do I need to change in this script, so the RM-click is disabled without displaying the alert-message? So just disabling the RM-button...

if(event.button==2)
{
alert('I don\'t thinks so!');
return false;
}

T.I.A

Don't eat yellow snow!
 
Try this one. It works on my local intranet site.

Code:
<script language="JavaScript">
<!--
//Disable right mouse click Script

function clickIE() {
	if (document.all) return false;
}

function clickNS(e) {
	if (document.layers||(document.getElementById&&!document.all)) {
		if (e.which==2||e.which==3) return false;
	}
}

if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;
} else {
	document.onmouseup=clickNS;document.oncontextmenu=clickIE;
}

document.oncontextmenu=new Function("return false")

// --> 
</script>

Hope it helps

Martin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top