Disable view background image

I’ve noticed when I visit some sites, right clicking to view an image is disabled, how are they able to do that.

Here is an example of one I found.

When you right click to view the image, it doesn’t work.

How are sites able to do this?

Is there a specific code that is used to do that?


Hi there asasass,

if you really wish to aggravate visitors and make
them leave your site in droves, use this javascript…

(function( d ) {
   'use strict';
    d.addEventListener( 'contextmenu', 
       function(e) {
         }, false);
}( document ));

It is a rather childish and amateurish thing to do. :rolleyes:


Hi there asasass,

as for the page that you linked to, I presume that you think that this…

…is a hidden background-image.

Well that is certainly not true. :unhappy:

If you click “View Source” and go to line #1032 you will find the
"img element " is buried amongst a whole bunch of CSS code !!! :rolleyes:

Validating the page consequently, revealed that the code has enumerable errors…




I was just wondering how that is done.

How what was done? :wonky:


Disabling click view background image. Because I’ve been seeing it more and more.

View Background Image” is a lighter grey shade not because it is
disabled, but because there is no background image to view. :rofl:


But if there is a picture there, how come “View Background Image” doesn’t work when you click that?

If it’s not a background image, what is it considered then?

It’s not a background image, it’s an img element. background-image is a CSS property, img is an HTML element.

Here you go:

1 Like

It is not considered anything, it is an “img element” .


You can right click and view an image element here.

But not here.

It looks like there’s a transparent div on top of the img element, so when you think you’re right-clicking on the image, you’re really right-clicking the transparent div. Kind of annoying. This isn’t a behavior I would recommend imitating.

I’m not even sure they were doing this to purposefully block people from viewing the image. It might have just been an accident. MANY years ago this sort of thing might have appealed to people who thought this would keep people from stealing their images, but that’s a very outdated way of thinking (anyone competent will be able to get to the image anyway), so I doubt that’s it. And if it is the case, that’s rather lame.

Pro tip: I see you’re using Firefox, so if you want to access any image on a page, you can right click anywhere on the page and choose “View Page Info” or “View Image Info”, and make sure you’re on the “media” tab of the window that pops up…then just keep scrolling through the images until you find the one you want.


Well, see what happens when you right click here…



1 Like

oh, ok, that’s how that’s done.


        No problem, you’re very welcome. :winky:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.