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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No Right Click and No Shift Click combined

Status
Not open for further replies.

Astor

Programmer
Jul 3, 2002
12
ES
I'm trying to achieve the no right click and the no shift click combined. I have a script that does the job individually, but when put in the same html only one effect occurs.

Can anyone help me put these two together?
Thanks.

<HTML>
<HEAD>
<title>JavaScript</title>

<script language=&quot;JavaScript&quot;>
<!--
function mouseDown(e) {
var shiftPressed=0;
if (parseInt(navigator.appVersion)>3) {
if (navigator.appName==&quot;Netscape&quot;)
shiftPressed=(e.modifiers-0>3);
else shiftPressed=event.shiftKey;
if (shiftPressed) {
alert ('Shift-click is disabled.')
return false;
}
}
return true;
}
if (parseInt(navigator.appVersion)>3) {
document.onmousedown = mouseDown;
if (navigator.appName==&quot;Netscape&quot;)
document.captureEvents(Event.MOUSEDOWN);
}
//-->
</script>

<script language=&quot;JavaScript&quot;>
<!--
var message=&quot;No Right Click.&quot;;
function click(e) {
if (document.all) {
if (event.button == 2) {
alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
// -->
</script>

</HEAD>
<body>

<a href=&quot;test.html&quot;>Test</a>

</BODY>
</HTML>
 
You're wasting your time. There's always a better way...
 
Take a look at thread216-380432 what's the point of trying to tell people not to bother with no right click scripts etc. Either help them with the code or don't help with the code. Your comment of &quot;your wasting your time&quot; is a waste of your time and of the person who asked. I agree that no right click scripts in javascript are easily bypassed, but many users on the net are not quite technical enough to figure out how to get around these scripts.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top