禁止鼠标点击事件
document.onmousedown = function mdClick(event) {
var e = event || window.event || arguments.callee.caller.arguments[0];
if (e.button == 2 || e.button == 3) {
return false;
}
};
禁止浏览器默认右键菜单操作
document.oncontextmenu = new Function("return false;");
监听键盘F12键操作
document.onkeydown = document.onkeyup = document.onkeypress = function(event) {
var e = event || window.event || arguments.callee.caller.arguments[0];
if (e && e.keyCode == 123) {
e.returnValue = false;
return (false);
}
}
本文介绍了如何使用JavaScript禁用网页上的鼠标右键点击事件、阻止浏览器默认的右键菜单操作,以及如何监听并阻止F12快捷键的操作。这些技巧对于保护网站内容不被轻易复制或调试有一定的作用。
8177

被折叠的 条评论
为什么被折叠?



