Disable Right Click?

Unchilled

Joined: 2003-03-04
Posts: 2
Posted: Tue, 2003-03-04 05:01

Hello,

I know how to disable right-click in basic HTML pages; just drop in the Javascript. But I don't have a clue how to do it in gallery. Can someone take a moment to explain a simple way to do it?

I appreciate the help.

-Unchilled

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Tue, 2003-03-04 08:48

If you only want to do it on image pages, then just open view_photo.html, look for <body> and add it there (or in the javascript section directly above it).

PS: once you get it working, share the code here so others can benefit.

PPS: I don't actually recommend doing it - it's irritating, and doesn't stop anyone who might actually misuse your images from getting them.

 
Unchilled

Joined: 2003-03-04
Posts: 2
Posted: Tue, 2003-03-04 16:54

After reading the tutorial over at eclecticpixels.com (Great site!) i got the idea to just drop the script in the wrapper.header file ( I didnt even know it existed ) and it works great. If anyone wants to ask me questions on how I did it just email me

By the way, I agree with you Joan, it is annoying, but this gallery doesn't belong to me I was just setting it up.

Thanks,

-Unchilled.

 
Gaile

Joined: 2002-07-20
Posts: 1301
Posted: Tue, 2003-03-04 19:15
Quote:
After reading the tutorial over at eclecticpixels.com (Great site!)

Thank you! :smile:

I use a "no right click script" that works for images only, so that if someone likes to use their mouse to navigate, it won't impede them. The script can be found at Dynamic Drive - look for "Disable right click script II (on images)- By Dynamicdrive.com". It needs to go at the bottom before the </body> tag, so stick it in the wrapper.footer (or at the bottom of each page you want to protect, up to you...)

I realize this isn't going to stop someone really determined, but it stops the casual right click and save people. I also disable Microsoft's Image Tool Bar (stupid thing, what WERE they thinking!!). AS WELL...you can add this little bit of code to your <body> tag:

ondragstart="return false" onselectstart="return false"
-- and images can't be dragged off the page in IE - but it doesn't stop Netscape users.

All that being said, the determined thief will either search his/her cache files for your images or take a screen print or whatever. I just try to give them lots of time to think about it while trying to remove an image from my site.

All artists have the right to say "NO, you can't take my images." You don't need a reason other than the image belongs to you.

And before I get too preachy on THAT subject.... :roll:

I'll sign off for now!

Gaile

 
phgrove

Joined: 2002-10-10
Posts: 101
Posted: Tue, 2003-03-04 20:18

These script are only useful for IE and NS, Opera will just ignore them!

 
Gaile

Joined: 2002-07-20
Posts: 1301
Posted: Tue, 2003-03-04 20:29

Hi phgrove

I believe I mentioned that the "ondragstart="return false" onselectstart="return false"
works only for IE.

The "no right click" script I use works in IE5+ and NS6+ (I'm assuming it works in older NS versions, but I no longer worry about them).

And yes, you are quite correct - Opera pretty much ignores all of them. I'm sure there are other browsers that also just ignore some of the preventative scripts.

You can always try a watermarking script (search the threads here) to protect your images. Or just use smaller images at low res that are no good for printing or doing much of anything with other than viewing.

There really isn't a failsafe method, sorry to say.

Regards,

Gaile

 
lovelife

Joined: 2002-10-15
Posts: 11
Posted: Tue, 2003-03-04 21:22
Quote:
>>
I realize this isn't going to stop someone really determined, but it stops the casual right click and save people. I also disable Microsoft's Image Tool Bar (stupid thing, what WERE they thinking!!). AS WELL...you can add this little bit of code to your <body> tag:

ondragstart="return false" onselectstart="return false"
-- and images can't be dragged off the page in IE - but it doesn't stop Netscape users.

I'm going to sound totally dumb but I can't find any body tags in mine. I used the other code you suggested and it works but I can't get the Microsoft Image Tool Bar to disable.

 
Gaile

Joined: 2002-07-20
Posts: 1301
Posted: Tue, 2003-03-04 22:30

Hi lovelife

Body tags - are on the albums.php, view_album.php, view_photo.php and the slideshow pages. On the albums.php it's around line 70 in the version I last downloaded (v1.3.4).

If you have a text editor, use the search function and search for the <body> tag - it should take you straight to it. A good text editor that is free is <!-- BBCode Start --><A HREF="http://www.crimsoneditor.com/" TARGET="_blank">Crimson Editor</A><!-- BBCode End -->.

As for the MS Image Toolbar - that is disabled by a meta tag. A quick example of where to put your meta tags is below, I used the head portion of the albums.php to illustrate meta tag placement and the body code I mentioned that prevents images being dragged off the page in IE:

<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE><html>
<head>
<title><?php echo $gallery->app->galleryTitle ?></title>

<!--put your meta tags here -->

<!-- the tag below is for disabling the MS Image Toolbar -->
<meta http-equiv="imagetoolbar" content="no">

<?php echo getStyleSheetLink() ?>
</head>

<body ondragstart="return false" onselectstart="return false"></TD></TR></TABLE><!-- BBCode End -->

That should help!

Gaile

 
lovelife

Joined: 2002-10-15
Posts: 11
Posted: Tue, 2003-03-04 23:17

Gaile, thank you so much!!! I didn't even look in those files so that explains why I couldn't find it. It works perfectly! Thanks for sharing those. :grin:

 
phgrove

Joined: 2002-10-10
Posts: 101
Posted: Wed, 2003-03-05 08:06

I spent some time trying different things, and bacisally there are aonyl a few options, water mark or make a table who background image is the image you want and then have a dummy image in the table cell. That way whent he user tries to steal the image they get the dummy image. Of course the source thml code will tell them where the image is so some extra security is needed, like html encrption like htmlguard, but on the fly. Anyway i have just added a watermark as that turned out easier.

Peter

 
nukestud
nukestud's picture

Joined: 2003-03-25
Posts: 114
Posted: Mon, 2003-05-12 23:50

I tried the following in veiwphoto.php as suggested but still have image toolbar :( Any ideas?

<head>
<title><?php echo $gallery->app->galleryTitle ?> :: <?php echo $gallery->album->fields["title"] ?> :: <?php echo $index ?></title>
<meta http-equiv="imagetoolbar" content="no">

 
darklotus

Joined: 2003-05-11
Posts: 29
Posted: Tue, 2003-05-13 14:28

here is a javascript no right click script:

<SCRIPT LANGUAGE="JavaScript">
var message="Function Disabled!";
///////////////////////////////////
function clickIE() {if (document.all) {alert(message);return false;}}
function clickNS(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=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")
// --> 
</script>

Just put that in the head of your page

 
rizzay

Joined: 2003-07-25
Posts: 36
Posted: Sat, 2003-09-06 02:24

Hi everyone. Thank you so much for the information about the right-click script. Does anyone know if it's possible to have the right-click disabled for Guests to a gallery, but allow logged-in users to save pictures? Are there specific PSP files for logged in users?

Thanks,
Mark

 
BorgKing
BorgKing's picture

Joined: 2002-09-12
Posts: 314
Posted: Sat, 2003-09-06 10:12

rizzay, there are no specific PHP files for logged in users. What you could do is put the right-click script between<?php if ($gallery->user->isLoggedIn()) { ?>and<?php } ?>

But I have to stress that it is far more effective when you only allow logged in users to see the full size photo (set this in album permissions).

If you really want to protect your images, use watermarking, because disabling right clicking only works to annoy your users. People who want to steal your images will still be able to do so easily.

 
rizzay

Joined: 2003-07-25
Posts: 36
Posted: Sat, 2003-09-06 20:12

Thanks BorgKing,
I was looking to use the right click only script for those just visitng my gallery. If the user logs in I want them to be able to right-click, view the full size, and save photos. I guess I'll stick with the permissions thing for now.

I've tried the auto watermarking but my host does not have/support the GD library (each on-the-fly ones i've read about in these forums require it.) I have thought about watermarking all my photos but on the fly would be much easier. Do you know of one that does not require that library?

Thanks,
Mark

 
BorgKing
BorgKing's picture

Joined: 2002-09-12
Posts: 314
Posted: Sun, 2003-09-07 00:16

Can't help you there, I don't use any image protection myself, my photos are not good enough for anyone to steal anyway ;)

Too bad GD libraries won't work for you, with watermarking on the fly you might even be able to only watermark photos when users are not logged in.

 
clothahump
clothahump's picture

Joined: 2002-11-26
Posts: 127
Posted: Tue, 2003-12-23 20:22

I know this is an old thread but: It works great apart from if you use XP, it just pops up the little save box in the corner?
Any way to disable that as well?

 
wls460

Joined: 2004-09-03
Posts: 8
Posted: Mon, 2004-09-13 17:52

I am looking to hide the toolbar when gallery is displayed inside my postnuke site. I have the code set up to work when the site is displayed as a new window but when it pops up inside the site the code is not working.

Any ideas?

 
newbie_girl

Joined: 2004-10-02
Posts: 3
Posted: Sat, 2004-10-02 13:05

Hi there.. I have been reading you posts and you seem to know a ton of info.

Heres the thing, I am helping a friend post his phots on a gallery.. and he is very stuck on having no right click, although I have explained the numerous ways to get around it.. anyway, here is my question. I know you can put the javascript in a html document to stop right clicking, however, if I have 400 photos do I have to put that code in 400 times?? Is there a way to make is easy to enter it? Any short cuts for disabling right click??

Thanks in advance!!

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Sun, 2004-10-03 00:49

Well... all of your Gallery thumbnail pages are created from one file: view_album.php, and all your Gallery image pages are created from view_photo.php.

So adding whatever code into those two pages should be a start. Or you could even add the Javascript into html_wrap/wrapper/wrapper.header to affect *all* gallery pages...

-Beckett (

)

 
morampudi2vidyasagar

Joined: 2009-07-21
Posts: 3
Posted: Tue, 2009-07-21 09:32

how to avoid right click on image gallery(your photos on u r website

 
morampudi2vidyasagar

Joined: 2009-07-21
Posts: 3
Posted: Tue, 2009-07-21 09:49

how to resize the image before saveing database

 
morampudi2vidyasagar

Joined: 2009-07-21
Posts: 3
Posted: Wed, 2009-07-22 08:41

how to Integration this gallery2. it is working..at my local host..but it is not up lode my site.when i click this gallery redirected to main page.and Error message have show plz.. help..me to Integration.part.

 
bananapatch

Joined: 2010-08-18
Posts: 1
Posted: Wed, 2010-08-18 19:58

This thread is almost 8 years old as I write this. I am amazed that nobody has pointed out the dreadful stupidity of disabling the right mouse button. It's not only futile, it will actually cripple your site.

You can't suppress an image or source code. You simply cannot. Trying to do so makes it appear as though you think you can, and that makes you look like an idiot.

If I want an image from your site, I will:

- grab the image from the cache.

- get the image location from the source and download it.

- disable javascript.

- drag the image into a Photoshop window.

- type

Quote:
javascript:void oncontextmenu(null)

into the address bar.

- take a screen shot of the image.

Worst of all, if you disable the right mouse button you are removing tons of important functionality from the user that they want to have, not just "save image". And if your user is left handed and has reoriented their mouse buttons, they won't even be able to click anything. It's about the dumbest thing a web developer can do.

If your image is so precious to you that you don't ever want it to be downloaded, don't post it. It is that simple.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Wed, 2010-08-18 20:22

Thank you for bringing up this dead thread. I'm locking it.

We've discussed this ad nauseam in other posts.

EDIT: and you are 100% correct, it's totally pointless to intentionally break a visitor's browsing experience.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here