Click to See Complete Forum and Search --> : Right-Click Disabled UNINTRUSIVELY!
pdxmitch
05-07-2003, 01:08 AM
I've seen scripts that disable right-click menus of images only (http://www.dynamicdrive.com/dynamicindex9/noright2.htm) (so as not to annoy people who right-click on benign items), and I've seen scripts that disable right-click menus silently (http://www.dynamicdrive.com/dynamicindex9/noright3.htm) (so as not to annoy people with rude "Gotcha!" alert messages), but I've never seen scripts with both features. Is such a script possible?
Thank you! A lot!
KeshavaR
05-07-2003, 01:31 AM
The simplest way to get into "Silent Mode" and for "Images" too without any coding, for Right Clicks :
<body oncontextmenu="return false">
No matter where the user right clicks on the page.
have a great day
Keshav
Vladdy
05-07-2003, 06:05 AM
First, any scripts like that are a waste of time - there is not much you can do about Print Screen button and other Image Capturing programs. There are also other ways to go around "no right-click" scripts, like disabling javascript.
If you want an unintrusive way to prevent complete morons from copying your images, make a transparent gif and do this:
<div style="background: url(yourrealimage.gif); width=100px; height=100px;"><img src="transparent.gif" width="100" height="100"></div>
pdxmitch
05-07-2003, 10:38 AM
You can, in effect, disable the Print Screen function by replacing <body> with <body onload=setInterval("window.clipboardData.setData('text','')",20)> . I don't want to disable right-clicking for all of the page, just for the images, and I don't want a notice popping up, I just want nothing to happen. Is that possible?
pdxmitch
05-07-2003, 10:47 AM
Oh! I didn't understand KeshavaR's post fully -- you can target just one image or individual images by adding...
oncontextmenu="return false"
...to just the image tag! So <img src="copyrighted.jpg" oncontextmenu="return false"> disables right-clicking on that image only. That's brilliant! So much simpler than the javascript way. And no annoying pop-up messages!
AdamGundry
05-07-2003, 10:53 AM
Only thing is, oncontextmenu is not valid HTML (it is IE-specific) and will fail if Javascript is disabled in the user's browser. Vladdy's method is more reliable, as it does not depend on JS.
Finally, though, the only way to truly protect your images is not to put them online in the first place.
Adam