Hướng dẫn chống copy bài viết và click chuột phải
Ta có 2 đoạn code như sau:
Code 1:
<script type="text/javascript" src="https://googledrive.com/host/0B1EJGJ56bNPuajFBWkdFUS1qdGM"></script>
<style>
body{
-moz-user-select: none !important;
-webkit-touch-callout: none!important;
-webkit-user-select: none!important;
-khtml-user-select: none!important;
-moz-user-select: none!important;
-ms-user-select: none!important;
user-select: none!important;
}
</style>
Code 2:
<style>
body {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
</style>
<script type="text/javascript">
//<![CDATA[
document.onkeypress = function(event) {
event = (event || window.event);
if (event.keyCode === 123) {
//alert('No F-12');
return false;
}
};
document.onmousedown = function(event) {
event = (event || window.event);
if (event.keyCode === 123) {
//alert('No F-keys');
return false;
}
};
document.onkeydown = function(event) {
event = (event || window.event);
if (event.keyCode === 123) {
//alert('No F-keys');
return false;
}
};
function contentprotector() {
return false;
}
function mousehandler(e) {
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if ((eventbutton === 2) || (eventbutton === 3))
return false;
}
document.oncontextmenu = contentprotector;
document.onmouseup = contentprotector;
var isCtrl = false;
window.onkeyup = function(e)
{
if (e.which === 17)
isCtrl = false;
}
window.onkeydown = function(e)
{
if (e.which === 17)
isCtrl = true;
if (((e.which === 85) || (e.which === 65) || (e.which === 88) || (e.which === 67) || (e.which === 86) || (e.which === 83)) && isCtrl === true)
{
return false;
}
}
isCtrl = false;
document.ondragstart = contentprotector;
//]]>
</script>
Như vậy là đã hướng dẫn xong mọi người cách chống copy bài viết và click chuột phải. Chúc thành công