Lưu ý: Code này sẽ vô hiệu hóa tác dụng của phím Ctrl, có nghĩa là các tổ hợp phím có dùng phím ctrl trong đó sẽ bị vô hiệu hóa (Copy: Ctrl + C ; Viewsourse:Ctrl + U ; Save: Ctrl + S).
Đồng thời bạn cũng không thể duy chuyển trang bằng các phím mũi tên lên và xuống.
![]() |
| Code chặn chuột phải cho blogger |
1. Code chống chuột trái
Chèn trước thẻ đóng
</head> <style type='text/css'>
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>
2. Code chống chuột phải
Chèn vào trước thẻ đóng</head> <script type='text/javascript'>
//<![CDATA[
// JavaScript Document
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>
3. Chống cả chuột trái và chuột phải
Kết hợp cả 1 và 2 ta sẽ có đoạn code sau, bạn cũng chèn trước thẻ đóng
</head> <style type='text/css'>
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'>
//<![CDATA[
// JavaScript Document
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>
4. Code chống Ctrl + U, chống viewsourse, chống F12
Chèn trước thẻ đóng
</head> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js'/>Và thay thẻ
<script type='text/javascript'>
checkCtrl=false $('*').keydown(function(e){
if(e.keyCode=='17'){ checkCtrl=false } }).keyup(function(ev){
if(ev.keyCode=='17'){ checkCtrl=false } }).keydown(function(event){
if(checkCtrl){
if(event.keyCode=='85'){ return false; } } })
</script>
</body> thành<body onkeydown="return false"> Lưu mẫu lại và kiểm tra
Chúc các bạn thành công!

BÌNH LUẬN (0)
Một số lưu ý khi bình luận
Mọi bình luận sai nội quy sẽ bị xóa mà không cần báo trước (xem nội quy)
Bấm Thông báo cho tôi bên dưới khung bình luận để nhận thông báo khi admin trả lời
Để bình luận một đoạn code, hãy mã hóa code trước nhé