CuDemVN.Wap.Sh



![]() | ![]() ![]() ![]() |
Code chống copy cho Website (dán đoạn code này vào CSS của bạn nhé)
<style>
body{
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
</style>
<script type="text/JavaScript">
function killCopy(e){
return false
}
function reEnable(){
return true
}
document.onselectstart=new Function ("return false")
if (window.sidebar){
document.onmousedown=killCopy
document.onclick=reEnable
}
</script>
Code chặn chuột phải cho Website
Nếu bạn muốn chống thêm cả thao tác chuột phải (hạn chế tình trạng sao chép ảnh và văn bản), thì đây là đoạn code... Vị trí thì bạn cứ để nó trước thẻ đóng head:
<script type="text/JavaScript">
var message="NoRightClicking"; function defeatIE() {if (document.all) {(message);return false;}} function defeatNS(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=defeatNS;} else{document.onmouseup=defeatNS;document.oncontextmenu=defeatIE;} document.oncontextmenu=new Function("return false")
</script>
Ở trên là đoạn CSS3 chống copy, -webkit, -moz, -ms, -o là để tương thích với các trình duyệt khác nhau, vì là CSS3 nên nếu trình duyệt nào chưa hỗ trợ đầy đủ thì nó không hoạt động, nghĩa là đối tượng vẫn copy được! Do vậy ta mới cần thêm JavaScript
- Cái này thì hoạt động tốt trên hầu hết trình duyệt.
Tuy nhiên JavaScript lại có điểm yếu là đối tượng có thể chủ động tắt JavaScript của trình duyệt để copy... Và đó là lý do ta nên kết hợp cả hai, vì CSS thì đối tượng lại không thể tự tắt. Phối hợp cả 2 làm cho chúng bù lấp các điểm yếu của nhau.
Nguồn: Tải Gì

Đánh giá: 4.5/ 5, 2240 bình chọn
