llVn0YjMLG9Y1gAZwSUYezIfBPNnRB1JIi7LpqAJ

Disable Right-Click and Copying on Your Blogger Site

Protect your content from being copied! Learn two effective methods to disable the right-click function on your Blogger blog today.
Male hand clicking computer mouse.
Image by Cadabra

If you want to make it harder for visitors to copy content from your Blogger site, one common method is disabling the right-click function. This can be done using either JavaScript or CSS.

Keep in mind that these methods mainly discourage casual copying. Advanced users can still bypass them using browser developer tools or by disabling JavaScript in their browser.

Method 1: JavaScript Implementation

Sign in to your Blogger account > Go to Layout > Click Add Gadget > Choose HTML / JavaScript > Then paste the code below into the widget area.

You can also insert the script directly into your Blogger theme above the </body> tag.

JavaScript 1

<script>
var message="Not Allowed";
var shouldAlert=1;
document.oncontextmenu=function(){
 if(shouldAlert==1){
  alert(message);
 }
 return false;
};
</script>

JavaScript 2

This script disables right-click, F12, Ctrl + Shift + I, Ctrl + Shift + J, and Ctrl + U keyboard shortcuts.

<script type='text/javascript'>
//<![CDATA[
    // disable right click
    document.addEventListenerundefined'contextmenu', event => event.preventDefaultundefined));
    document.onkeydown = function undefinede) {
        // disable F12 key
        ifundefinede.keyCode == 123) {
            return false;
        }
        // disable I key
        ifundefinede.ctrlKey && e.shiftKey && e.keyCode == 73){
            return false;
        }
        // disable J key
        ifundefinede.ctrlKey && e.shiftKey && e.keyCode == 74) {
            return false;
        }
        // disable U key
        ifundefinede.ctrlKey && e.keyCode == 85) {
            return false;
        }
    }
//]]>
</script>

Method 2: Applying Cascading Style Sheets (CSS)

While signed in to Blogger, go to Theme > Customize > Advanced > Add CSS.

Copy and paste the CSS code below into the custom CSS field, then click Apply to Blog.

If the CSS does not work, go back to Theme > Edit HTML, then search for <b:skin> using Ctrl + F. Paste the CSS code directly below it, then save the theme.

CSS 1

.post-body {
       -webkit-user-select: none;       /* Chrome all / Safari all */
       -moz-user-select: none;          /* Firefox all */
       -ms-user-select: none;           /* IE 10+ */
       -o-user-select: none;
       user-select: none;
}

CSS 2

*{user-select:none}*::selection{background:0}*::-moz-selection{background:0}
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */

Final Thoughts

Disabling right-click and text selection can help discourage simple content copying on your Blogger site, especially from casual visitors.

However, no method can completely prevent content theft online. These techniques should mainly be viewed as basic deterrents rather than full protection against copying.

Post a Comment
Please read our comment policy guidelines before posting.