Skip to content

Instantly share code, notes, and snippets.

@minichiello
Created December 12, 2009 02:31
Show Gist options
  • Save minichiello/254683 to your computer and use it in GitHub Desktop.
Save minichiello/254683 to your computer and use it in GitHub Desktop.
Prevents the copying of texts
<script type="text/javascript">
document.oncontextmenu = function(){return false}
document.onselectstart = function(){
if (event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type != "password")
return false;
else
return true;
};
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;
}
}
if (parent.frames.length > 0) top.location.replace(document.location);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment