Page 1 of 1

[HACK] Disable Copy

Posted: Wed Aug 26, 2009 7:45 pm
by SamX
Some users wants to protect your images or description on your store

To Disable Right Click with Text (It works on Firefox too)

Open templates/YourTemplate/Panels/HTMLHead.html

Before </head> add:

Code: Select all

<script language=JavaScript>
<!--
var message="Your Site - www.yoursite.com";
///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
1
}
}
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>
To disable Text Selection:

Before </head> add:

Code: Select all

<script language="JavaScript1.2">

// IE
document.onselectstart=function(){
if(event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type != "password")
return false
else return true;
};
// FIREFOX
if (window.sidebar){
document.onmousedown=function(e){
var obj=e.target;
if (obj.tagName.toUpperCase() == "INPUT" || obj.tagName.toUpperCase() == "TEXTAREA" || obj.tagName.toUpperCase() == "PASSWORD")
return true;
/*else if (obj.tagName=="BUTTON"){
return true;
}*/
else
return false;
}
}
</script>
With this script the users canĀ“t select text but can use search and login boxes.

Enjoy