PDA

View Full Version : no right click script


walkamongus
04-19-2010, 06:26 PM
my client would like me to implement this code to disable right clicking on images... does the code look okay? And do i just place it in the header? Any help is much appreaciated

<SCRIPT language=Javascript1.2>
<!--
var message='Right Click Disabled .';
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>
</a>

d a v e
04-19-2010, 07:32 PM
don't do it.
it annoys users makes pages less accessible and it's next to pointless.

js can easily be disabled
print screen
image taken from the cache...
waste of time for him, you and the user

walkamongus
04-19-2010, 07:48 PM
thanks for the reply dave. yes, im aware of how pointless and annoying disabling right clicking is, explained it to my client as well, but he still wants it done :/ i was handed this code to use, but im not very java-savvy

domedia
04-19-2010, 08:35 PM
Good grief..
The problem is that it's not only annoying for the visitors that will never come back, it's a guaranteed way to lose money.

In order to make the code work, place it in the header section of the website <head>, just make sure you don't bring along the closing </a>.

.

walkamongus
04-19-2010, 09:01 PM
thanks for the reply domedia. I placed it in the head but its not working for me. i found a similar code that works...

<script language=JavaScript>
<!--

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Function Disabled!";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

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

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

// -->
</script>

..but i would like to get the original code to work for the sake of pleasing the client. not sure what the problem is :/ any more help is appreciated

oh and i did away with that </a>

domedia
04-19-2010, 09:18 PM
I would just tell your client that the code he provided did not work, but that you went to the extra length of finding one that did.
Really should be no issue. :)

walkamongus
04-19-2010, 09:35 PM
Yeah you're probably right, thanks for the advice!

edbr
04-20-2010, 10:29 AM
there are bucket loads of them if the client insists though

http://www.google.com/search?q=disable+right+click+javascript&ie=utf-8&oe=utf-8&aq=t&client=firefox-a&rlz=1R1GGGL_en___ID330

d a v e
04-20-2010, 05:18 PM
personally i would just refuse to do it ;)
or do it and then go round to their place and show them how easy it is to take the image, along with some google searches of how easy it is to find ways of doing it.

walkamongus
04-20-2010, 10:33 PM
hi edbr, thats how i found the dynamic drive script and it seems to be working "great".

dave, perhaps emailing them an article would have helped, but i spoke up about it twice, and its really up to them as far as im concerned.

anyway, thanks again everyone

domedia
04-20-2010, 10:36 PM
and its really up to them as far as im concerned. True, sometimes you have to be a business man and not a developer.