top of page

Preventing copying text in a webpage 😁

Preventing copying text in a webpage 😁

This feature is really important if you have a very very unique content website or an online eBook. So here is the basic post and required post for all of you. In this post, we'll see how to prevent copying text on a webpage and I have got a bonus too. Simple and Basic ONE! -> This is the simple tutorial for preventing the copying of an element on the web-page. Ex. p, div, main. So here is how we can do that.



<div id="test" onmousedown='return false;' onselectstart='return false;'><!-- So we're disabling the texts coming under div tag-->

Using CSS


-> You can directly disable by using CSS by just applying these properties to the whole body, you can move them to a classand apply that classto the elements you want to disable select.



h2 {-youbkit-touch-callout: none;

-youbkit-user-select: none;

-moz-user-select: none;

-ms-user-select: none;

user-select: none;


Disabling Right Click

-> So technically no chances of copying.

We will use JavaScript and jQuery



document.oncontextmenu = new Function("return false;");$(document).ready(function () {
    $("body").on("contextmenu",function(e){
        return false;
    });
});

// jQuery
Ā 
Ā 
Ā 

Comments


©2020 by Leisure Tech Time.

​

bottom of page