How to Disable Right Click on Blogger or Java enabled Websites
http://iamsamer.blogspot.com/2012/12/how-to-disable-right-click-on-blogger.html
Today I have very accurate blocking all the right mouse click for any Blogger hosted blog or website. This time I have a script which will block all the right clicks on your Blogspot blog or your Java script supported website. This script is developed on Java interface. This is a simple Java script which will not only disable right mouse click but shows a "warning message" to the clicker also.
Note: This script will work only if the visitor's web browser has Java script enabled. But don't worry more than 90% browsers by-default has enabled Java scripts. However it is possible that anybody can manually disable the Java script feature and in this situation this script will not work. But as I know most of the people don't know about it. This script disables the right-click option for the entire blog or website.
Blogger Java Script to Block/ Disable Right Click for entire Blog or Website:
<script language="javascript">
var message="This function is not allowed here.";
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>
Please Take a Backup of your Template before any editing.
And then Copy the above script and paste it at your Blogger in Edit HTML Mode, Just before the your closing head tag. </head>. Just copy and paste above code just above the Closing head tag and save your template. Now Check out how does your script is working.
This Java script will show a Warning Pop up Window as shown in the screen shot above. It will show a warning message "This function is not allowed here." but you can change this message from any message you want to display by changing the text in Red color in the script code. For any help or problem feel free to share.
or if you Like this post helpful so please comment below to appreciate my work.
Excellent! This is very useful. Thanks for sharing the javascript code and tweeted :)
ReplyDeleteThanks for the post.. Disable is working fine on PC. But not wort on Android smart phone..
ReplyDeleteAny solution to this