If you want the right click option to be disabled on all pages in your blog then follow the instructions below. If not then you can just place the code in the post that you want to disable it in. Make sure if you paste it in a post you do so in Edit HTML mode.
If you feel uneasy about adding coding directly into your template you can add this code into a HTML/javascript gadget instead. But its better to add it through your template for best results because some scripts may have a bleed over effect on your Page Elements as well.
Design--> Edit HTML--> Ctrl+F--> Input </head> in the Find bar that comes up.
This should locate the </head> tag in your HTML page.
Place this code directly above the </head> tag.
<script type="text/javascript">
document.onmousedown=disable; //IE
message="Sorry no right click on this page!";
function disable(e)
{
if (e == null)
{ //IE disable
e = window.event;
if (e.button==2)
{
alert(message);
return false;
}
}
document.onclick=ffdisable; //FF
}
function ffdisable(e)
{
if (e.button==2)
{ //firefox disable
e.preventDefault();
e.stopPropagation();
alert(message);
return false;
}
}
</script>
You can change the text in red to the alert message you wish to display when someone right clicks.
document.onmousedown=disable; //IE
message="Sorry no right click on this page!";
function disable(e)
{
if (e == null)
{ //IE disable
e = window.event;
if (e.button==2)
{
alert(message);
return false;
}
}
document.onclick=ffdisable; //FF
}
function ffdisable(e)
{
if (e.button==2)
{ //firefox disable
e.preventDefault();
e.stopPropagation();
alert(message);
return false;
}
}
</script>
Thank youuuuuuuuuuuuuuuuuuuuuuu
ReplyDeleteso much
Thanks so much for this. I had to mess about some to find where to put in the script, but it works. I even customized it! look and see, http://robins-chaos.blogspot.com
ReplyDeleteHi I tried to find this but could not locate the head tag? would it be because of the template I use? kriznizzel/blogspot.com/
ReplyDeleteThanks
thank for your sharing
ReplyDeletecurry on friend...:)
thanks...great job...
ReplyDeleteunfortunately this did not work for me when I tested it :(
ReplyDeleteYou might have JavaScript disabled on your browser or your browser does not support it.
ReplyDeleteAnother question for you Aires! I am trying to add this into a single post. When I ctrl- f'd the edit html part of my post, not only did the exact head tag you mentioned not show up, the word 'head' didn't even appear. Any ideas?
ReplyDeleteIf your using the new dashboard it renders the HTML code page in iframe or AJAX and the browser find box will not be able to find the tag requested. You can switch to the old dashboard or scroll through the coding and find it manually. In most blogs the head tag is found about 60-80% down the page.
ReplyDeleteNo, I even pasted the whole code into Word and ctrl F'd- nothing :( It just isn't there!?
ReplyDeleteIf your using a 3rd party template they may have tweaked the template coding with additional tweaks which would stop it from being pulled up if the head code was tweaked. The head tag must exist because it is part of a HTML documents standard structure. Send me a email through the contact at the top of this blog. It will not let you add the full template coding in the email but once I reply back you can do so.
ReplyDeleteTahnks a lot, man, very useful tool.... :)
ReplyDelete