View Full Version : How to disable right-click on images w/o alert message?

03-26-2008, 09:37 PM
Could anyone tell me the code to disable right-clicking on images WITHOUT an alert message popping up?

Now i using this code

<script language="JavaScript1.2">

var clickmessage="Right click disabled on images!"

function disableclick(e) {
if (document.all) {
if (event.button==2||event.button==3) {
if (event.srcElement.tagName=="IMG"){
return false;
else if (document.layers) {
if (e.which == 3) {
return false;
else if (document.getElementById){
if (e.which==3&&e.target.tagName=="IMG"){
return false

function associateimages(){

if (document.all)
else if (document.getElementById)
else if (document.layers)

how to disable "Right click disabled on images!" from this code

03-26-2008, 10:11 PM
There's no point, and this is just annoying.
If you insist on pretending to protect your images (and trust me, it is just pretending) you can google for a lot of codes, and there are some on this website.
However, it will not work on every OS/browser, and you also won't actually protect anything... at all.
You'll stop the stupid people, but the real thieves will know how to get around it. Additionally, you'll just annoy a lot of people who don't mean to cause you harm, but might want to look at the image, or save it (but not to hurt you), or just have a habit of clicking and suddenly find that their mouse button isn't working...

03-26-2008, 10:23 PM
Is the any chance you answer me to that question ?

p.s I ask google and no Joy

03-26-2008, 10:28 PM
Took me 4 seconds to type that.
And, look, fifth link:

And the answer is still that you're wasting your time. If this sounds harsh, then I'm sorry for that, but it's the truth and someone needs to tell you. You can't protect the images. Everyone tries, everyone fails, then figures out it's not worth it. Just trying to speed it along for you. Not that your idea is bad.

03-26-2008, 10:38 PM
this is not for image ... this diseble right click on all web page :(

i want just for images and yes i know this is not sense but i have to do it for my expirience

03-26-2008, 10:46 PM
Well, the search certainly has a lot of results.

But that doesn't work in NS4+ (including FF).

Keep searching, but as I've said, you'll find that none of them work fully, so you won't ever find "it".

03-27-2008, 03:16 AM
Once you publish something in your site it becomes very difficult to protect them in a meaningful manner especially the images. Mostly the people used to disable the right-clicking just to protect their image. But unfortunately you won't be able to protect the images in this manner as the user can take the images using different other techniques like they can save the page and under normal circumstances the image will be downloaded to their PC or they can use some screenshot takers for getting the images without much difficulty.

As Daniel pointed out it is almost impossible to protect your images by diabling the right click.

03-27-2008, 03:18 AM
And to be fair, perhaps you have another purpose for this. If that is the case, then explain that, not just that you want a working no right click script, and maybe there's a way around it. There are a few occasions where something like this can help, and sometimes some solutions, too.