How to Block Right-Click to Protect Images

If you have images (or anything else) on your website that want to protect then you can disable “right-click”, which is how people get to the “Save As” option. This is not a perfect solution because anyone with advanced web experience can get around this, but it will stop most people from stealing anything you have a copyright on. You can use any (no need to use more than one) of the codes below to block “right-click” functionality, which will prevent most attempts to save your stuff.

Once you have selected the code from below that you want to use, follow these steps…

  1. Log in to your Website Tonight account.
  2. Click the Site tab (upper left).
  3. Use the Manage drop-down menu to select Launch Page Designer.
  4. Navigate to the page where you want right-click disabled.
  5. Click the Page tab (top center).
  6. Hover over the Properties icon and select JavaScript.
  7. Paste the code you select from below into the box titled JavaScript for <head>
  8. Repeat steps 4-7 for each page were you want right-click disabled.
If there is already code in the box then be sure not to delete or replace anything. Simply scroll to the bottom of the box, hit enter on your keyboard a couple times to add some blank lines, and paste the new code there.
You can customize the message the user sees when they attempt to use the “right-click” on their mouse by changing the red text from the code you select below. ONLY replace the red text. If you accidentally delete the quotes around the red text it will break the code.


Disable Right-Click

<script type="text/javascript">
var message="Right-Click Disabled!";
function clickIE4(){
if (event.button==2){
alert(message); return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
</script>

Disable Right-Click Without an Alert Message

<script type="text/javascript">
var message="";
function clickIE() {
if (document.all) {
(message);return false;
}
}
function clickNS(e) {
if (document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {
(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS;
}else{
document.onmouseup=clickNS;
document.oncontextmenu=clickIE;
}
document.oncontextmenu=new Function("return false")
</script>

How to Disable Right-Click on Images Only

<script type="text/javascript">
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"){
alert(clickmessage);
return false;
}
}
}else if (document.layers) {
if (e.which == 3) {
alert(clickmessage);return false;
}
}else if (document.getElementById){
if (e.which==3&&e.target.tagName=="IMG"){
alert(clickmessage);
return false;
}
}
}
function associateimages(){
for(i=0;i

Leave a Reply