Saturday, September 26, 2020
Home Blogging Tips & Tweaks How to Disable Right Click Option on Images in Blogger Posts

How to Disable Right Click Option on Images in Blogger Posts

One of the most important ingredients added to blog posts to make it more interesting and engaging are images. A blog post without an image or picture to go with is like a thousand pages novel handed over to a 5 year old child to read. Just imagine how boring that will be to the child. It is without saying that most readers of posts in a blog gets insights on what that post might be trying to portray by just glancing through the images on it. So if you are one of those blog administrators or owner who hardly use image on posts, you should consider adding one or two to every post you publish to make the post more user friendly and interesting for your blog visitors.

Having said that, it is very important that the images you use on your blog posts are unique and so shouldn’t be found randomly on other blogs. Speaking of uniqueness, as long as the image is live on the internet, there is no way you will tell users not to copy them and they will heed to it. Forget about the copyright laws which you should have heard about. There are people who don’t mind, they simply copy anything they like without permission. For this reason I have decided to show you guys how you can be able to protect the images you use on your blog posts by disabling the right click option on them. We are simply going to make use of a script which I will show you guys how to add to your blog’s template HTML code. To do this, just go through the guide below

Disabling Right Click Option on Images in Blogger

To disable right click on images in a blogger posts,

  • Log into your Blogger Dashboard.
  • Navigate to Template >>> Edit HTML.
  • Click anywhere inside the Edit HTML box page and search for </head> using Ctrl + F.
  • Copy the script below and paste just after/below the </head> tag.
<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 = "Right click on images disabled by blog’s Admin. Please right click anywhere besides on an image to view the right click context menu.";
    document.oncontextmenu = nocontext;
//]]>
</script>
  • When you add the above script below the </head> tag in your blog’s template code, users who try to use the right click option on your blog to copy an image will get a pop alert.

If you do not want the alert box to show up when users try to right click on your blog images, then use the script below;

<script type='text/javascript'>
//<![CDATA[
    function nocontext(e) {
        var clickedTag = (e==null) ? event.srcElement.tagName : e.target.tagName;
        if (clickedTag == "IMG") {
            return false;
        }
    }
    document.oncontextmenu = nocontext;
//]]>
</script>
  • After adding that, click on Save Template and you are done.

With that done, you have simply disabled the right click option on images in your blog posts. Any questions? Feel free to ask using the comment box below.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

List of All JavaScript Arithmetic Operators With Examples

JavaScript offers several operators to help us work with numbers. All these operators are binary operators, which means they operate on two operands. The operands...

How to Find a Website’s RSS Feed’s URL

Having access to the RSS feed of a website gives you the opportunity to stay up-to-date on everything that website publishes. Whether that’s a...

Laravel: String data, right truncated: 1406 Data too long for column (SOLVED)

I was working on a project today when i ran into the error message "String data, right truncated: 1406 Data too long for column...

How to Enable or Disable Chrome’s Autofill on Android Devices

Storing your login details and other information in Chrome and/or your Google Account isn’t as secure as using an encrypted password manager, but it’s...

Recent Comments