onbeforeactivate 对象要被设置为当前元素前立即触发。//这个禁用了按键功能
设置onbeforeactivate解决了JavaScript 1行 1列 跳出脚本错误!
右键禁用JavaScript
</script>
<script type="text/javascript" src="js/jquery1.42.min.js"></script>
<script type="text/javascript">
function OnActivate(e)
{
if (event.keyCode) {
return true;
}
return false;
}
$(function () {
//禁用右键
document.body.onbeforeactivate = OnActivate;
document.body.oncontextmenu = document.body.ondragstart = document.body.onselectstart = function () { return false; };
document.body.onselect = document.body.oncopy = document.body.onmouseup = function () { return false;/*document.selection.empty();*/ };
})
</script>
禁用网页右键与按键功能
本文介绍了一种通过JavaScript禁用网页上的右键菜单和特定按键功能的方法,使用了onbeforeactivate事件来阻止默认行为,并展示了如何利用jQuery简化实现过程。
2336

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



