Hi all,
i've a page with many images on it and i have to disable right click
menu on the images of class 'items' so that's what i do:
$$('.items').each(function (img) {
img.observe('mousedown', function (e) {
var button;
if (window.event) {
button = e.button;
} else {
button = e.which;
}
if (button > 1) {
e.stop();
return false;
}
});
img.observe('mouseup', function (e) {
var button;
if (window.event) {
button = e.button;
} else {
button = e.which;
}
if (button > 1) {
e.stop();
return false;
}
});
});
But right click menu is still working... where's my mistake?
on 2008-06-29 18:07
on 2008-06-29 20:56
that seemed to work for me in FF3, make sure the 'items' class name is
on each img.
Also you might want to try the contextmenu event...
$$('.items').each(function(i) {
i.observe('contextmenu', function(e) {e.stop();})
});
on 2008-06-30 00:21
This might catch more:
$$('.items').each(function(i) {
i.observe('contextmenu', function(e) {e.stop();})
}).observe('click',function(e) { if (e.isRightClick()) e.stop(); });
on 2008-06-30 00:22
"contextmenu" (as darrin pointed out) works quite reliably, except for
Opera which simply ignores it:
$$('.items').invoke('observe', 'contextmenu', Event.stop);
-- kangax
On Jun 29, 12:10 pm, Stefano Esposito <stefano.esposit...@gmail.com>
on 2008-06-30 08:17
On Jun 30, 2:10 am, Stefano Esposito <stefano.esposit...@gmail.com> wrote: > Hi all, > > i've a page with many images on it and i have to disable right click > menu on the images of class 'items' so that's what i do: Attempting to disable the context menu is usually done to try and stop people copying text or images from a site. It is futile exercise, as anyone who wants to copy content will work out how to do it without using the context menu. All you end up doing is removing functionality for no good reason, which is a really good way to annoy users. -- Rob
on 2008-06-30 21:01
On Sun, 29 Jun 2008 23:16:37 -0700 (PDT) RobG <rgqld@iinet.net.au> wrote: > Attempting to disable the context menu is usually done to try and stop > people copying text or images from a site. It is futile exercise, as > anyone who wants to copy content will work out how to do it without > using the context menu. All you end up doing is removing > functionality for no good reason, which is a really good way to annoy > users. Poor, little Troll :P Thanks for the contextmenu hint, it worked like a charm... not on Opera, of course, but i don't have to support it, luckily enough. :) Ciao, Stefano
on 2008-06-30 21:57
Actually, RobG is a regular contributer and gives some pretty good advice. I certainly wouldn't stick a "troll" label on him so quickly.
on 2008-06-30 22:59
> Attempting to disable the context menu is usually done to try and stop > people copying text or images from a site. It is futile exercise, as > anyone who wants to copy content will work out how to do it without > using the context menu. All you end up doing is removing > functionality for no good reason, which is a really good way to annoy > users. Locking down source is a futile effort, but allowing custom context menus is a fabulous feature. I find the Context Menu in Google Documents to be quite a delightful UI option, I would have no use for the standard menu in that view. -- Matt Foster Ajax Engineer Nth Penguin, LLC http://www.nthpenguin.com
on 2008-06-30 23:04
On Mon, Jun 30, 2008 at 3:58 PM, Matt Foster <mattfoster01@gmail.com> wrote: > Locking down source is a futile effort, but allowing custom context > menus is a fabulous feature. I find the Context Menu in Google > Documents to be quite a delightful UI option, I would have no use for > the standard menu in that view. True enough, but this thread is clearly about blocking right-clicks on certain elements (images) for the sole purpose of stopping people from saving the images. -justin (not a troll)
on 2008-07-01 17:27
At the risk of being called a troll, I thought I'd just ask: Why not use image cloaking? Doing that would prevent users from saving images even better than the right-click disable, as it would also prevent them from saving the image by dragging it from the page to their desktop. With cloaking, you'd write some css to place a transparent gif directly over the images you want to protect, so that when users tried to save the image, they'd just end up with the transparent image, instead of the one you don't want them to save. This would also cover the ol' drag off the page trick, where the right click option wouldn't. I'm on the anti-disable-right-click side of the fence, obviously, as there are more features in that contextual menu than just 'save this image'. There's also 'bookmark this page', and I'd imagine you'd want your users to have access to that. :) On Jun 29, 11:10 am, Stefano Esposito <stefano.esposit...@gmail.com>
on 2008-07-01 18:49
On 01 Jul 2008, at 17:26, Jeff Keen wrote: > the ol' drag off the page trick, where the right click option > wouldn't. > > I'm on the anti-disable-right-click side of the fence, obviously, as > there are more features in that contextual menu than just 'save this > image'. There's also 'bookmark this page', and I'd imagine you'd want > your users to have access to that. :) Still, View Page Source will still get the user what he wants. It's a fake sense of security. The only way to protect images on your website from distribution, is by visible watermarking (using RMagick for example). Then they can save all they want, the picture will never be usable somewhere else without having your mark on it, no matter how subtle it is. So: watermark the image using RMagick, write it away in a public accessible file (with the watermark) for caching, so you don't have to run each image through RMagick every time (only the non- watermarked pictures will need to be generated). Best regards Peter De Berdt
on 2008-07-01 19:18
The only other thing i can think of is actually making Ajax requests and using the css hack of embedding images as binary arrays in css. That way they can only get binary data out of your system. But even that probably has its problems.... bottom line if you dont want people to steal.. then you are probably going to have to use proprietary systems like flash... but then again print screen is always avaialable. If its on the web then its fair game. Michael Stephens Electrical Engineering Graduate Student University of Wyoming falcon@uwyo.edu or 89iroc@gmail.com On Tue, Jul 1, 2008 at 10:48 AM, Peter De Berdt <peter.de.berdt@pandora.be>