HTML for No Right Clicks

Images can be Protected With HTML

When you're creating a web page, using HTML for "No Right Clicks" can help protect the images on the page from being easily copied. It's not perfect protection, but it will turn away some picture thieves.

Copyright and the Web

The digital age has been a mixed blessing for artists and photographers. While it has become easier than ever for artists to share their images online, it has also become very easy for people to steal the same images and sometimes even claim them as their own. There have been many technologies created to attempt to thwart this, and using HTML for "No Right Clicks" code is one of the first lines of defense.

What Does "No Right Click" Mean?

The right-click is the alternative selection mode for most computer mice (on Apple, it is the control-click). For images, it will give people the option to "copy image" or "save image" to their hard disk. Using a few lines of code, however, you can change the way a viewer's computer interacts with the page. Sometimes you can even chastise them for trying to steal the image in the first place.

HTML for No Right Clicks

There are many different ways to go about making "right clicking" difficult. They all involve javascript, and are variations on checking which mouse "event" button is being pushed down. In the following example, you would place the code in the <HEAD> section of the document. The code will generate a popup alert window with a message the moment someone does a right click.

<script language="JavaScript"><!-- var NoClick="Sorry, this is my image; if you want to use it, please email me for permission"; 

The first part of the code doesn't actually generate the popup window - instead, it creates a variable called "NoClick" that will contain the message in the alertbox. That message can be anything you'd like it to be, including your email address or copyright information.

The next code is the function that actually detects the mouse click, anywhere on the document:

function noway(go){ if (document.all){ if (event.button == 2)

Then the alert box calls that "NoClick" variable to send your anti-copying message:

{ alert(NoClick); return false; } }

This code is particularly designed for Internet Explorer. As a result, there is more code needed to compensate for document layers and the way that browser reads mouse events:

if (document.layers){ if (go.which == 3) { alert(popup); return false; } } } if (document.layers){ document.captureEvents(Event.MOUSEDOWN); } document.onmousedown=noway; // --></Script>

Other Methods

That is only one way to deal with right clicks. Using Dynamic HTML, for example, you would use the code found on Dynamic Drive. You can also find a javascript method that covers both Netscape (Mozilla) based browsers as well as Internet Explorer at the Javascript Source.

BrownieLocks goes a bit further, providing not only ways to prevent image theft but also showing HTML for "no right clicks" code that protects text. She also provides a lot of information and opinion about web theft and intellectual property in general. All of these sources are quick to note that the methods are not foolproof. They will only stop people who only have a basic understanding of web technologies.

You Can't Stop the Signal

While the javascript code can keep people from easily copying the image in the way they are most accustomed to, it is by no means foolproof. With screen capture available in just a couple of keystrokes, the fact is that if they can see the image they can copy it. Other people will use tricks such as making all the images on a page have a "rollover" effect that replaces it with a blank or watermark image. You can also use some programs that will search the web to find your images where other people may use them, using software from companies such as Digimarc.

However, putting this simple javascript code into your document will at least let them know that you care about your images enough to make the effort. It can help encourage respect for copyright and make the web a better place for everyone.

Was this page useful?
Related & Popular
HTML for No Right Clicks