News:

Wondering if this will always be free?  See why free is better.

Main Menu

JavaScript: Disable Right Click

Started by ilearnmath.net, August 17, 2010, 12:24:21 AM

Previous topic - Next topic

ilearnmath.net

Quick question: I have the script to accomplish, just need some help finding the appropriate place to paste it so that it disables right click everywhere in the portal. I use Simple Portal. Script instructions for a simple html page are to paste the javascript in the header and call it in the body tag.

KensonPlays

Where is this script found? You might be able to take JUST the JS and put it into a script/html block and make visibility hidden.

Owner of Mesozoic Haven

ilearnmath.net

The script is currently embedded in a plain html file in the portal.

Sweet. this will definitely do it. (why couldn't i think of that)  thank you Kcmartz.

The reason I wanted the disabled right click feature is so i can protect images, but I have found a far better solution: wrapping the images in flash container.

DoctorMalboro

<script language=JavaScript>
<!--

//Disable right mouse click Script
//By Maximus ([email protected]) 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>


try this code... just change alert(message); with alert(Do not leech, sucka!); or whatever you want to :P

ilearnmath.net

Thank you, DoctorMalboro. i had found something similar the other day. i sure would like to use that alert message :)

Did some reading on this and found the right click alerts can be disabled in some browsers after a few consecutive attempts. i was able to do this in chrome at least.

Roph

You still cannot stop people. The flash file must still request the images, and thus they are easy to get. Even if you hide them inside the SWF itself, they are still trivial to retrieve. :)

ilearnmath.net

thanks for the heads-up Silverline, and for sharing the two useful tips :)

KensonPlays

yes the DynamicDrive script is awesome! they all are on that site! and your welcome!

Owner of Mesozoic Haven

Advertisement: