View Full Version : Image-pop and no right click


Jrfan888
05-07-2003, 09:38 PM
I am using a javascript code for an image pop up...when you click on the the link, a window pops up (its resizes on its own) with the image...i was wondering is there anyway i can put the no right click code in the window with the pic? (i didnt make a page for it...its a the java code that pops up with the image...no other page)

amicus
05-07-2003, 10:00 PM
this should work in both ie and netscape:

<script language="javascript">
var message="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>

you do realize that if the user is savvy enough he'll still be able to get the images or code. there's very little you can do to prevent it other then copyrighting your material.

Jrfan888
05-08-2003, 08:56 PM
that didnt work......?
Thanks though :)

and yeah i know that someone can still get my material...heh, i know all the ways, too.....

SSPrincess
05-08-2003, 09:15 PM
what a sec, did the javascript work? 'Cause I'm looking for something similar....

amicus
05-08-2003, 09:16 PM
i just checked the script and it works. are you putting the script in the head tags? do you have a piece of your code. this javascript goes on the page that you want to disable the right mouse click.

Jrfan888
05-08-2003, 10:07 PM
yeah im sure it works on a regular page...but im usingthis (http://www.codelifter.com/main/javascript/autosizeimagepopup.html) code for an image pop-up...so i sure thats y it wont work within the pop-up...?

amicus
05-08-2003, 10:38 PM
i'm not sure what you mean. the popups on the link you gave doesn't contain the script. the contents of the page shouldn't matter so long as the script is located on the page you want to disable the right mouse click.

Jrfan888
05-08-2003, 11:00 PM
oh, well i though it would matter b/c the picture is located only in the pop-up window, and i didnt make another seperate page for the pop up window, so there really isnt any HTML content to the window with the pic.

amicus
05-08-2003, 11:13 PM
create a .js file with the script in it and add the line below to the code that dynamically generates the popup window.

<script src="yourJSFile.js"></script>

or

writeln( "<script src='yourJSFile.js'></script>" );

for you i'm pretty sure it's one of those. the idea is that you source in the javascript and once you generate the popup you generate the code at the same time. i'm not sure if this will work but it should. usually you don't dynamically create an entire page but it's worth a shot.