Created
August 21, 2015 04:15
-
-
Save minhbxn/ec03d19bc94a5aa5b7a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script id="wpcp_disable_selection" type="text/javascript"> | |
//<![CDATA[ | |
var image_save_msg='You Can Not Save images!'; | |
var no_menu_msg='Context Menu disabled!'; | |
var smessage = "Copy đi, DMCA ở dưới kìa"; | |
function disableEnterKey(e) | |
{ | |
if (e.ctrlKey){ | |
var key; | |
if(window.event) | |
key = window.event.keyCode; //IE | |
else | |
key = e.which; //firefox (97) | |
//if (key != 17) alert(key); | |
if (key == 97 || key == 65 || key == 67 || key == 99 || key == 88 || key == 120 || key == 26 || key == 85 || key == 86 || key == 83 || key == 43) | |
{ | |
show_wpcp_message('You are not allowed to copy content or view source'); | |
return false; | |
}else | |
return true; | |
} | |
} | |
function disable_copy(e) | |
{ | |
var elemtype = e.target.nodeName; | |
elemtype = elemtype.toUpperCase(); | |
var checker_IMG = ''; | |
if (elemtype == "IMG" && checker_IMG == 'checked' && e.detail >= 2) {show_wpcp_message(alertMsg_IMG);return false;} | |
if (elemtype != "TEXT" && elemtype != "TEXTAREA" && elemtype != "INPUT" && elemtype != "PASSWORD" && elemtype != "SELECT") | |
{ | |
if (smessage !== "" && e.detail >= 2) | |
show_wpcp_message(smessage); | |
return false; | |
} | |
} | |
function disable_copy_ie() | |
{ | |
var elemtype = window.event.srcElement.nodeName; | |
elemtype = elemtype.toUpperCase(); | |
if (elemtype == "IMG") {show_wpcp_message(alertMsg_IMG);return false;} | |
if (elemtype != "TEXT" && elemtype != "TEXTAREA" && elemtype != "INPUT" && elemtype != "PASSWORD" && elemtype != "SELECT") | |
{ | |
//alert(navigator.userAgent.indexOf('MSIE')); | |
//if (smessage !== "") show_wpcp_message(smessage); | |
return false; | |
} | |
} | |
function reEnable() | |
{ | |
return true; | |
} | |
document.onkeydown = disableEnterKey; | |
document.onselectstart = disable_copy_ie; | |
if(navigator.userAgent.indexOf('MSIE')==-1) | |
{ | |
document.onmousedown = disable_copy; | |
document.onclick = reEnable; | |
} | |
function disableSelection(target) | |
{ | |
//For IE This code will work | |
if (typeof target.onselectstart!="undefined") | |
target.onselectstart = disable_copy_ie; | |
//For Firefox This code will work | |
else if (typeof target.style.MozUserSelect!="undefined") | |
{target.style.MozUserSelect="none";} | |
//All other (ie: Opera) This code will work | |
else | |
target.onmousedown=function(){return false} | |
target.style.cursor = "default"; | |
} | |
//Calling the JS function directly just after body load | |
window.onload = function(){disableSelection(document.body);}; | |
//]]> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment