Home How To Blogging Tips SEO

Pages

Jun 26, 2012

How to Disable Right Click to Prevent Copying of Images?

Being a blogger or content creator we add images to our posts. Images express more than words. But when someone visits your website or blog they simply right click on the image to save and use it in their content. There are lot of functions of right-click like page reloading, open link in new tab etc. So disabling right click on image is enough. To disable right click on images follow the instructions


 1. To disable right click on all images - Go to your blogger dashboard, click on Template then click on Edit HTML and click tho proceed and Expand widget templates and copy the following code immediately after </head>

<script type="text/javascript">
//<![CDATA[
function nocontext(e) {
        var clickedTag = (e==null) ? event.srcElement.tagName : e.target.tagName;
        if (clickedTag == "IMG") {
            alert(alertMsg);
            return false;
        }
    }
    var alertMsg = "Image context menu is disabled";
    document.oncontextmenu = nocontext;
//]]>
</script>


2. To disable right click on single image - Normal image tag will be like this
<img  border="0" src="url of image" /> 
To disable right click ad this code in image tag
oncontextmenu='alert("Image context menu is disabled");return false;'


Final tag will ne like this
<img oncontextmenu='alert("Image context menu is disabled");return false;'  border="0" src="url of image" /> 
You can change the highlighted text according to your wish. For demo click on following image. Hope this helps!
Disable Right Click on Images
You May Also Like

3 comments:

  1. This is a good piece of information. Thank you for this.

    ReplyDelete
  2. This works - except in Chrome you can override this by clicking Prevent this page from creating additional dialogs. Once you click that box, right click becomes available again.

    ReplyDelete
    Replies
    1. @RB - Thanx a lot yaar for Sharing this info..

      Delete

Criticism Accepted :)