I need a working script for prohibiting users from saving images on their machine. (Is it only possible through disabling right-click?)
Yes, I know that it is impossible, and yes I know that it is a bad practice.
Yes, I also know that I am an idiot. But I need this solution for some specific purposes.
Thanks!
You could try to replace all the
<img>elements with<div>elements that have the same size and use the image as a background:I’m using jQuery because DOM manipulation like this is a bit of a nightmare in raw JavaScript (and because this isn’t a free code writing service). This won’t stop anyone but it will keep them from dragging the images off your page or doing a “Save As…” from the context menu. This sort of thing also won’t do anything if your users disable JavaScript.
Example: http://jsfiddle.net/ambiguous/4Hca3/
I’ll leave translating this to whatever JavaScript libraries (if any) you’re using as an exercise for the reader.
You can try disabling the context menu but not all browsers (such as Firefox) will pay attention to that sort of chicanery.