Forum Moderators: open

Message Too Old, No Replies

Need help with javascript problem

         

thunderpaste

11:07 pm on Nov 30, 2004 (gmt 0)

10+ Year Member



I am using javascript to prevent image theft by eliminating the right click option. My problem is that it is also preventing people from selecting the text fields to fill out the checkout form when using firefox, netscape, mozilla. Can someone look at this code and see if that particular function can be removed or disabled while preserving the image protection? Any help is much appreciated.

<script>
<!--
document.write(unescape("%3Cscript%20language%3DJavaScript%3E%0D%0A%3C%21--%0D%0A%0D%0A%0D%0Avar%20message%3D%22%22%3B%0D%0A///////////////////////////////////%0D%0Afunction%20clickIE%28%29%20%7Bif%20%28document.all%29%20%7B%28message%29%3Breturn%20false%3B%7D%7D%0D%0Afunction%20clickNS%28e%29%20%7Bif%20%0D%0A%28document.layers%7C%7C%28document.getElementById%26%26%21document.all%29%29%20%7B%0D%0Aif%20%28e.which%3D%3D2%7C%7Ce.which%3D%3D3%29%20%7B%28message%29%3Breturn%20false%3B%7D%7D%7D%0D%0Aif%20%28document.layers%29%20%0D%0A%7Bdocument.captureEvents%28Event.MOUSEDOWN%29%3Bdocument.onmousedown%3DclickNS%3B%7D%0D%0Aelse%7Bdocument.onmouseup%3DclickNS%3Bdocument.oncontextmenu%3DclickIE%3B%7D%0D%0A%0D%0Adocument.oncontextmenu%3Dnew%20Function%28%22return%20false%22%29%0D%0A//%20--%3E%20%0D%0A%3C/script%3E%0D%0A%0D%0A%0D%0A%3Cscript%20language%3D%22JavaScript1.2%22%3E%0D%0A%0D%0A//Disable%20select-text%20script%20%28IE4+%2C%20NS6+%29-%20By%20Andy%20Scott%0D%0A//Exclusive%20permission%20granted%20to%20Dynamic%20Drive%20to%20feature%20script%0D%0A//Visit%20http%3A//www.dynamicdrive.com%20for%20this%20script%0D%0A%0D%0Afunction%20disableselect%28e%29%7B%0D%0Areturn%20false%0D%0A%7D%0D%0A%0D%0Afunction%20reEnable%28%29%7B%0D%0Areturn%20true%0D%0A%7D%0D%0A%0D%0A//if%20IE4+%0D%0Adocument.onselectstart%3Dnew%20Function%20%28%22return%20false%22%29%0D%0A%0D%0A//if%20NS6%0D%0Aif%20%28window.sidebar%29%7B%0D%0Adocument.onmousedown%3Ddisableselect%0D%0Adocument.onclick%3DreEnable%0D%0A%7D%0D%0A%3C/script%3E"));
//-->
</script>

Thanks.

Rambo Tribble

2:56 am on Dec 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just make your images each a background for an img tag that loads a transparent .gif.
The GIF can be any actual size, but specify in the tag the dimensions of the image being used as a background.
You can use the same actual GIF for each of your images, so the overhead is minimal.
It works better for blocking saving and it doesn't mess with the interface.