20 October 2008

Disabling Right Click in Blogger Blog

Have you noticed, that some web sites do not allow their visitors using right mouse click while pointer is on the blog area. This option is useful for the site and blog owners, who want to minimize the possibilities of the content direct copying to other posts.

Provided cross browser DHTML script from dynamicdrive will help you achieving the same result on your own blog, preventing default right menu from popping up when right mouse is clicked. There are actually two options for this script are provided: Alert Option and Non-alert Option. If the Alert Script is enabled, if someone tries to execute Right click on the blog, then a Message, which can be customized per your desire, appears. If the Non-alert script is activated, then no message is displayed.

To setup this tool in your blog Copy the Following code and paste it to your blog by adding a new page element.

Message Alert Script:

<script language=JavaScript>
<!--

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

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>


Message Non-Alert Script:

<script language=JavaScript>
<!--

//Disable right click script III- By Renigade (renigade@mediaone.net)
//For full source code, visit http://www.dynamicdrive.com

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")
// -->
</script>

9 comments:

  1. thanx It's all r perfectly working
    Thank u so much

    ReplyDelete
  2. Thank you for nice feedback!

    ReplyDelete
  3. Thank you very, very much! I really appreciate you posting this code for others.

    I've been having a problem with a multitude of users copying my Blog content and posting it on their own site as there own with no credit of were it came from.

    ReplyDelete
  4. Hi John,
    Thank you for your warm words. I agree that there is quite frequent nowdays when the authors content is reposted with no respect and reference to the original poster.

    ReplyDelete
  5. thank you so much!
    finally i can post my pics without worrying others taking'em :)

    ReplyDelete
  6. Allenisya,
    Note that disabling right click will just disable right click. You can still use keyboard for the image selection.

    ReplyDelete
  7. Hi Michael
    Thank you very much for this tutorial, it works perfect on my blog.
    If you like hand made things visit my blog:
    http://hechoamano-handmade.blogspot.com/

    Cheers and God bless

    Nuria from Spain

    ReplyDelete
  8. Thanks so much!
    I can finally post my story up here =)
    THANKS again!

    flyre.blogspot.com

    ReplyDelete
  9. Thanks! Your article is really very helpful for bloggers. It feels very bad when someone steals your hard work within few mouse clicks. Thanks again and keep up the good work.

    ReplyDelete

LinkWithin

Related Posts Plugin for WordPress, Blogger...