Kênh 360 Công Nghệ Kênh 360 Công Nghệ

Trang chủ

Tắt chức năng chuột phải bằng Javascript

Hướng dẫn tắt chức năng chuột phải bằng Javascript trên các trình duyệt web. Hiển thị thông báo khi người dùng bấm chuột phải.
Chèn đoạn mã này vào bất cứ vị trí nào trong tài liệu HTML của bạn.
Tips: Lưu đoạn mã từ phần khai báo biến message đến
đoạn document.oncontextmenu=new Function("return false;");
thành 1 file tienich.js
Sau đó chèn Mã Javascript vào thân tài liệu HTML:
<script type="text/javascript">
<!--
//Disable right mouse click Script
var message="Nút chuột phải không có tác dụng!";
// Internet Explorer
function clickIE4(){
if (event.button==2){
alert(message);// Gửi thông báo
return false;
}
}
// Nescape
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
//alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("return false;");
-->
</script>

Lần cập nhật cuối ( Thứ hai, 06 Tháng 7 2009 09:02 )  

Kênh 360 công nghệ

  • Nổi bật
  • Tin mới
  • Game mới
  • PrestaShop
English French German Japanese Korean