How to disable right click, Copy and Paste function

by Ismail.EL
0 comment


Contents

How to disable right click, Copy and Paste function

Most of the bloggers and webmasters uses JavaScript technique to disable right-click, in this article i show you how to disable right-click in your web site, with this solution you can slow users down by using Javascript to disable easy right click copy and paste:

* Create an HTML file  test.html as following<!DOCTYPE html>

<html>
<body><p id=”demo”></p>
<script type=”text/javascript” src=”monscript.js”></script>
<script type=”text/javascript”>
var message=””;
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function(“return false”)
function disSel(target){
if (typeof target.onselectstart!=”undefined”)
target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!=”undefined”)
target.style.MozUserSelect=”none”
else
target.onmousedown=function(){return false}
target.style.cursor = “default”
}
window.onload = function () {
document.body.onselectstart = function () { return false;}
document.body.ondragstart = function () { return false; }
}
disSel(document.body)
</script><head>
</br></br></br>
Place your script here to disable!!!
</head>
</br>
an Other message her 🙂
</body>
</html>

You can use the script below so when someone right clicks to save an image off your page, a message will come up letting people know that your information is copyrighted.

* Create an HTML file test.html as following:<!DOCTYPE html>

<html>
<head>
<script language=JavaScript> var message=”Function Disabled!”; function clickIE4(){ if (event.button==2){ alert(message); return false; } } function clickNS4(e){ if (document.layers||document.getElementById&&!document.all){ if (e.which==2||e.which==3){ alert(message); return false; } } } if (document.layers){ document.captureEvents(Event.MOUSEDOWN); document.onmousedown=clickNS4; } else if (document.all&&!document.getElementById){ document.onmousedown=clickIE4; } document.oncontextmenu=new Function(“alert(message);return false”) </script>
</head>
<body>
<span><img src=”/media/user/my-files/project/WED-LOGO1.png” width=”300″ height=”150″ border=”0″ alt=”Protected Image.”></span>
</br>
this image is protected against right-click 🙂
</body></html>

Conclusion

In this post, i have explained How to disable right click, Copy and Paste function
If you have any questions or feedback, feel free to leave a comment.
As always, if you found this post useful, then click like and share it 🙂

21750cookie-checkHow to disable right click, Copy and Paste function

Related Posts

Leave a Comment