3 WAYS TO DISABLE RIGHT CLICK ON A WEBPAGE—CSS AND HTML

The struggle to protect our own works and ensure that our posts, pictures and publications are not plagiarized or copied without due reference is one that writers and webmaster have been fighting since the beginning of writing.

 

The ancient Egyptians and Romans chained books and parchments to shelves in libraries to prevent unauthorized removal or stealing of works without destroying them. Modern day libraries put in the use of library cards and online libraries have restricted the downloading of works and also implemented login functions.

 

But, what happens when you post plain text or images on your blog or webpage, you can’t prevent people from right clicking on your webpage and copying stuff.

 

Or can you?

 

This post is set to teach you how to disable right click on your blog whether WordPress, Blogger, Wix or whatever platform you are using. In this post I will show you three ways to disable right click on your page.



disable right click

 

 

DISABLE RIGHT CLICK USING CSS

 

This method is foolproof given that most people don’t know about it and it is not easily bypassed, unlike Javascript. Here, we make use of the user-select CSS property to disable right click in any CSS class of our choice. Let’s assume teh CSS region you want to disable is a body CSS class [.body]. Just copy the code below and add to your site’s CSS to disable right click.

 

.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;

}

 

DISABLE RIGHT CLICK USING HTML

 

When you are writing the script for your site on your own, it is a child’s job disabling right clicks by adding oncontextmenu handler in the body tag of a webpage.

 

SO to do this when you are using a custom theme, view the code of your webpage. Search for the <body>, and the oncontextmenu handler to it as

 

<body oncontextmenu=”return false;”>

 

If that doesn’t work try:

 

<body oncontextmenu=”returnfalse;”>

 

Save the changes and right click will be successfully disabled on your page.

 

Miracle Chinonso

I'm a Medical student from Nigeria. You'd be wondering what a medical student is doing on a blog like this? Well, read on and find out. You can contact me through the comments section of each post. *Wink*

Leave a Reply

Your email address will not be published. Required fields are marked *