留作自用
document.oncontextmenu = null;
enableSelection(document.body);
function enableSelection(target) {
if (typeof target.onselectstart != "undefined")
// IE
target.onselectstart = null;
else if (typeof target.style.MozUserSelect != "undefined")
// Firefox
target.style.MozUserSelect = "";
else
{
target.onmousedown = null;
target.onmouseup = null;
}
target.style.cursor = "";
}
本文介绍了如何使用JavaScript编写代码来禁用页面元素的上下文菜单,并实现自定义选区功能,包括针对不同浏览器的兼容性处理。

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



