capturing NS7 mousedown events

admin

Administrator
Staff member
I am attempting to discourage surfers from copying images on my site by displaying an alert. The version of the code I currently use works in everything except NS7.

This code below (from The JavaScript Source: Page Details: No Right Click) also does not seem to work in NS7... is there something I'm missing? Is there a way to do what I'm looking to do? I have a feeling it's something simple...

Thanks in advance for your help!

Ed
=================

<HEAD>

<SCRIPT LANGUAGE="JavaScript1.1">
<!-- Original: Martin Webb (<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->) -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! <!-- m --><a class="postlink" href="http://javascript.internet.com">http://javascript.internet.com</a><!-- m --> -->

<!-- Begin
function right(e) {
if (navigator.appName == 'Netscape' &&
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' &&
(event.button == 2 || event.button == 3)) {
alert("Sorry, you do not have permission to right click.");
return false;
}
return true;
}

document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;
// End -->
</script>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<center>[ Try right-clicking the image and then the text link below ]
<p>
<img src=http://www.webdeveloper.com/forum/archive/index.php/"http://javascript.internet.com/img/tjsbutton.gif">
<p>
<a href="http://javascript.internet.com/page-details/no-right-click.html">No Right Click Link</a>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 1.57 KB -->

=================

For your reference, here is the code as I currently use it:

=================

<Script language="JavaScript">

<!-- NoScript
// Present a notice asking the user not to save the image
function NoSave() {
date = new Date();
year = date.getYear();
if (year < 1900) {
year += 1900;
}
mesg = "This image is Copyright " + year + "Portrait & Wedding Gallery\n";
mesg += "All Rights Reserved.\n";
alert(mesg);
return false;
}
// NoScript -->

</Script>

<Script language="JavaScript1.2">

<!-- NoScript
// Present a notice asking the user not to save the image
function NoSave(e) {
if (navigator.appName == "Netscape") {
if (e.target.name == "ViewedImage" && e.which != 1) {
date = new Date();
year = date.getYear();
if (year < 1900) {
year += 1900;
}
mesg = "This image is Copyright " + year + "Portrait & Wedding Gallery\n";
alert(mesg);
return false;
}
return true;
} else {
date = new Date();
year = date.getYear();
if (year < 1900) {
year += 1900;
}
mesg = "This image is Copyright " + year + "Portrait & Wedding Gallery\n";
alert(mesg);
return false;
}
}

// Capture mousedown events
if (navigator.appName == "Netscape") {
document.captureEvents(Event.MOUSEDOWN);
document.onMouseDown = NoSave;
}
// NoScript -->

</Script>

<img src="sunset.jpg" onmousedown="NoSave()" name="ViewedImage" width="352" height="265" border="0" alt="sunset">
 
Back
Top