/    Sign up×
Community /Pin to ProfileBookmark

disable rightclick on a popup-image?

Hi!
Im using an image popup script on my gallery, but it’s not mine, so I have trouble figuring out how to disable rightclicking.
Is there anyone who is willing to help me out here? any help will be gladly taken ?

Below is the script I’m using in <head>:


******************************

function image_open(image_loc,img)
{
HTML = “<html><style>body{margin:0px 0px 0px 0px}</style><body onBlur=’top.close()’><img src='”+ image_loc +”‘ border=0 name=load_image onLoad=’window.resizeTo(document.load_image.width+10,document.load_image.height+60)’></body></html>”;

popupImage = window.open(”,’_blank’,’toolbar=no,scrollbars=no’);
popupImage.document.open();
popupImage.document.write(HTML);
popupImage.document.close();
obj_img = document.getElementById(img);
obj_img.src= obj_img.src;
}

to post a comment
JavaScript

19 Comments(s)

Copy linkTweet thisAlerts:
@KorDec 07.2005 — 
I have trouble figuring out how to disable rightclicking.
[/quote]

Don't waste your time. If someone wants to copy an image by all means, it will do it for sure. Web space was not built in order to hide or deny copying. Everything you open in browser is downloaded in user's bowser's cache anyway. Or the user might simply save the whole page and retreive the pictures afterwards... Don't waste your time with this kinda stuff.
Copy linkTweet thisAlerts:
@ZaziauthorDec 07.2005 — please, that is not what I'm asking for, and that's the same **** I'm been reading on all the other posts about right clicking, trust me...I NOW!!!!

I don't care if there is other ways to copy the images, they are watermarked, and it's a image POPUP, not a new page, so people won't need their rightclick menus. I simply want to know how to add a rightclick disabling into my already working JS, because most people who are going to see the pictures aren't geeks and pros so they don't know how to drag-and-drop the pictures...

Again, please help...don't tell me that I shouldn't... ?
Copy linkTweet thisAlerts:
@KorDec 07.2005 — 
they are watermarked
[/quote]

a simple Print Sceen will blow up your watermak. Or even a Photoshop summary processing on them. Believe me, It woun't worth. there is [COLOR=Red][B]absolutely no way[/B][/COLOR] to prevent images copying.
Copy linkTweet thisAlerts:
@FromU2MEDec 07.2005 — There are several scripts on javascript.internet.com that you can use for [B]no right click[/B]!
Copy linkTweet thisAlerts:
@FromU2MEDec 07.2005 — Kor - as Zazi said, his users aren't geeks nor pros! And PhotoShop, for one, is a pretty much advanced ? so...

If he wants to create a no-right-click page let him do so! If you want to complain on somebody - do so on those poor ******** who spent their time creating all those no-right-click-scripts in the first place! :p
Copy linkTweet thisAlerts:
@soccermatrixDec 07.2005 — on the body tag.

<body oncontextmenu="return false">.
Copy linkTweet thisAlerts:
@KorDec 07.2005 — Kor - as Zazi said, his users aren't geeks nor pros! And PhotoShop, for one, is a pretty much advanced ? so...

If he wants to create a no-right-click page let him do so! If you want to complain on somebody - do so on those poor ******** who spent their time creating all those no-right-click-scripts in the first place! :p[/QUOTE]


There is no logic in this argument. If someone wants to copy a picture, it might be no harm in it. If he wants to [b]use[/b] it, that could be a problem. Or people which want to use a picture for their purposes are not amateurs. So that why building a low wall to prevent leopards' jumpings over? :rolleyes: There is no wall enough high to stop that. This is it.
Copy linkTweet thisAlerts:
@ZaziauthorDec 07.2005 — Kor, I am ignoring you, please leave it!!!

FromU2ME, thanx ?

But the thing is that I have already found many scripts, but what I want is to disabel right click in an image popup window, so there is no way to add a script in either head or body tag, because there is no page to add it to...that's why I wonder if there is any possibilities to add it to the image-popup script on the gallery page..If you understand? If I'm not explaining myself good enough please let me know, I'm not english, so I suck ?
Copy linkTweet thisAlerts:
@FromU2MEDec 07.2005 — I see what you mean, you want the popup only to be an image (ex. file.jpg) and not a html document! Unfortunatelly, you cannot disable right clicks that way since you need some sort of script to do it for you - sorry! ?
Copy linkTweet thisAlerts:
@FromU2MEDec 07.2005 — The best way is probably to use a HTML document for this purpose and use the code given by soccermatrix earlier! If you know any server-side scripts that makes it all easier.
Copy linkTweet thisAlerts:
@ZaziauthorDec 07.2005 — bah, that's what I was afraid of, but thank you anyway, now I can give up searching ?

Maybe I just use html documents for my pictures, I do have a few server-side scripts..yeah yeah...anyway, thanx everyone ?
Copy linkTweet thisAlerts:
@KorDec 07.2005 — 
Kor, I am ignoring you, please leave it!!!
[/quote]

ok... as you wish... I know that the wisdom's voice is almost always ignored... :rolleyes:

Come on... Can't u see how many intricate things (and how useless, as I said) you must to consider? When left click a link, a picture is shown as a popup. What could stop user to right click on that link and chose "Save Target As"...? Well, another right click disabling code on that link either. But if the user [B]left[/B] cliks on that link (or on that picture in popup) and drag'n drop it to the address bar? Surprise!...The picture is brought in browser as a locally downloaded file, ready to be copied... So that you need to disable left click as well. But if you disable the left click, you can not open the pop-up... :rolleyes:

Ok, OK, don' read this, ignore me. Wise advices are only for wise listeners, I know, I know...
Copy linkTweet thisAlerts:
@kelly23Dec 07.2005 — It looks to me like you have access to the html so why not put:

oncontextmenu='return false'

... in the body tag of the html that you show in the function that opens that window, or did I misunderstand you?

Replace the HTML variable in your function with this:

HTML = "<html><style>body{margin:0px 0px 0px 0px}</style><body [b]oncontextmenu='return false'[/b] onBlur='top.close()'><img src='"+ image_loc +"' border=0 name=load_image onLoad='window.resizeTo(document.load_image.width+10,document.load_image.height+60)'></body></html>";
Copy linkTweet thisAlerts:
@FromU2MEDec 07.2005 — Kor - there are [B]MANY[/B] ways to save an image from a website! I can name a dozen ways to prevent that - but at least a dozen plus one ways to save the image on my harddrive anyway! ?

The question here is whether somebody should use these dozen ways to prevent image copying or not - because it's up to the person who owns the website to decide if it shall have a few copy protecters or not.

Don't missunderstand me right :p I'm actually on your side of the matter that you should not use no-right-click-scripts etc. because it IS annoying. Though, if somebody wants to use it that's fine by me... at least I know I'll never put one of those scripts on my website and I guess it's the same with you!

I'm of this thread now! If you want to discuss this any more then pm me! ?
Copy linkTweet thisAlerts:
@kelly23Dec 07.2005 — I see nothing wrong with using this approach along with watermarking, etc. to "cut down" on image copying. I have customers who are professional photographers for whom image copying is a real concern. No, it's not going to stop everyone from getting an image if they really want it, but it can certainly discourage the normal viewer. Remember, not everyone who views your site is knowledgeable about viewing the source code, image paths, javascript or how to find an image in their temporary internet files, etc.

I don't know how you can say putting a simple little script in the head of your document is "not worth it". We're not talking about hours of work here. ?

As long as the designer understands that this method is not foolproof, then I say why not?
Copy linkTweet thisAlerts:
@gamesinfinityDec 07.2005 — ok i found a code that disables right clicks...although you shouldn't, but here's the code anyway....just copy this and put it near the bottom or top of the source

have fun!

<script language="JavaScript1.2">

/*

Disable right click script II (on images)- By Dynamicdrive.com

For full source, Terms of service, and 100s DTHML scripts

Visit http://www.dynamicdrive.com

*
/

var clickmessage="Copyrights do not allow this function."

function disableclick(e) {

if (document.all) {

if (event.button==2||event.button==3) {

if (event.srcElement.tagName=="IMG"){

alert(clickmessage);

return false;

}

}

}

else if (document.layers) {

if (e.which == 3) {

alert(clickmessage);

return false;

}

}

else if (document.getElementById){

if (e.which==3&&e.target.tagName=="IMG"){

alert(clickmessage)

return false

}

}

}

function associateimages(){

for(i=0;i<document.images.length;i++)

document.images[i].onmousedown=disableclick;

}



if (document.all)

document.onmousedown=disableclick

else if (document.getElementById)

document.onmouseup=disableclick

else if (document.layers)

associateimages()

</script>
Copy linkTweet thisAlerts:
@ZaziauthorDec 07.2005 — Kelly23, thanx..that was what I was looking for, now I just need to remove the image toolbar somehow, but that's another story. And thanks for standing up for me..hehe? I am perfectly aware of that it is anoying, but the viewers of this page don't care about right clicking or not, it's just something the owner of the images want to have.

And to you Kor, as I already said...I KNOW about the different ways to copy the image, I KNOW that it is not possible to prevent people to copy it...please don't be a wiseguy..thanx!
Copy linkTweet thisAlerts:
@kelly23Dec 07.2005 — now I just need to remove the image toolbar somehow[/quote]
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
Copy linkTweet thisAlerts:
@felgallDec 08.2005 — <script language="JavaScript1.2">

/*

Disable right click script II (on images)- By Dynamicdrive.com

For full source, Terms of service, and 100s DTHML scripts

Visit http://www.dynamicdrive.com

*
/

var clickmessage="Copyrights do not allow this function."

function disableclick(e) {

if (document.all) {

if (event.button==2||event.button==3) {

if (event.srcElement.tagName=="IMG"){

alert(clickmessage);

return false;

}

}

}

else if (document.layers) {

if (e.which == 3) {

alert(clickmessage);

return false;

}

}

else if (document.getElementById){

if (e.which==3&&e.target.tagName=="IMG"){

alert(clickmessage)

return false

}

}

}

function associateimages(){

for(i=0;i<document.images.length;i++)

document.images[i].onmousedown=disableclick;

}



if (document.all)

document.onmousedown=disableclick

else if (document.getElementById)

document.onmouseup=disableclick

else if (document.layers)

associateimages()

</script>
[/QUOTE]




[b]oncontextmenu="return false"[/b] added to the body tag does the same thing as the above code as well as blocking the context menu key on the keyboard which the above code doesn't check for (at least it does this on crappy web browsers that allow the context menu to be disabled at all).



Why use dozens of lines of code to do half of what one command can do?
×

Success!

Help @Zazi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...