Forum Moderators: open

Message Too Old, No Replies

Right click alert

can I confine it to a single image?

         

webboy1

1:58 pm on Apr 16, 2002 (gmt 0)

10+ Year Member



I have the following script to put on my page to disable the right mouse click. I however am not a big java expert, so can someone possibly help me edit it slightly please.

What i want is basically what this script does, but want it to do only on a selected image, not on the full screen as it does currently.

Any ideas?

Regards
webboy

This is the script.

<script language=JavaScript>
var message="Copyright Colin Palmer";
function click(e) {
if (document.all) {
if (event.button==2¦¦event.button==3) {
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>

PsychoTekk

2:07 pm on Apr 16, 2002 (gmt 0)

10+ Year Member



you could use <img src="some.gif" oncontextmenu="return false;">
no message pops up, very nice i think

DrDoc

11:40 pm on Apr 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or, if you name the image (using the NAME attribute) you can change ..

document.onmousedown=click;

.. to ..

document.the_name_of_the_image.onmousedown=click;

avyworld

12:24 am on Apr 22, 2002 (gmt 0)

10+ Year Member



* Shakes Head *

Efforts to protect anything on the web are futile. If you really don't want your images stolen, don't put them on the web.

If you really think it is necessary, though, assign your image an ID attribute and when the event occurs check the ID to see if it matches.

Hope that helps!

Happy coding! :)

JustTrying

1:16 am on Apr 22, 2002 (gmt 0)

10+ Year Member



Print Screen software make right-click futile anyways.

txbakers

1:58 am on Apr 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Print Screen, full download, View Source from the menu bar, etc. etc. etc.

The only way to protect your images is to put a watermark with your URL.

"Stolen from www.mysite.com"

DrDoc

7:18 am on Apr 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, txbakers, even that won't protect it. You can still steal the image using print screen.

But, that's besides the point. So called "protection" will only prevent honest people from stealing your stuff, just like locking your car only stops an honest person from taking it. Right? ;)

webboy1

7:58 am on Apr 22, 2002 (gmt 0)

10+ Year Member



cheers guys for all the input!!!

I agree with all your comments. The image in question was not mine. We were wanting to use someone elses image, and this was one of his conditions.

I have already told him we will not do that.

Thanks again.

Filipe

4:52 pm on Apr 26, 2002 (gmt 0)

10+ Year Member



When you say watermark, you mean like an invisible watermark with owner info? What if you were to put a blatant icon or logo over a part of the image like, say, IGN or NVTECH? That way it's very clear if an image is stolen (when you see it on another site) unless they're whizzes with Photoshop and the area where the logo was doesn't have anything that complex underneath.