When you upload pictures to your Blogspot blog, you have little control over who can view and download them. No matter what browser a visitor to your website uses, he is able to right-click on your blog with his mouse and use the "Save Image" command to download your pictures to his computer. The only way to disable picture downloading in Blogspot is by adding a JavaScript code that disables the right-click function. Since JavaScript cannot be added by editing your layout's HTML code, add the JavaScript code to a new page element instead.
Without Alert:
Navigate to Blogger.com and log in to your account.
Click the "Design" link below your blog's name under the Manage Blogs section.
Click any one of the "Add a Gadget" links on the page.
Wait for the Add a Gadget window to open, and then scroll down the Basics section and click the "HTML/JavaScript Add" link.
Copy and paste the following JavaScript code in to the "Content" box; leaving the "Title" box empty:
<script language=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")
// -->
</script>
<!--
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>
Click the "Save" button below the "Content" box.
Click the "Preview" button at the top of the page to open your Blogspot blog.
Right-click on your blog to test that the function has been disabled.
With Alert:
Navigate to Blogger.com and log in to your account.
Click the "Design" link below your blog's name under the Manage Blogs section.
Click any one of the "Add a Gadget" links on the page.
Wait for the Add a Gadget window to open; then scroll down the Basics section and click the "HTML/JavaScript Add" link.
Copy and paste the following JavaScript code in to the "Content" box, leaving the "Title" box empty:
<script language=JavaScript>
<!--
var message="Right-Click 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>
<!--
var message="Right-Click 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>
Click the "Preview" button at the top of the page to open your Blogspot blog.
Right-click on your blog to test that the function has been disabled.
No comments:
Post a Comment