oncontextmenu 事件禁用右键菜单
document.oncontextmenu = function(){
event.returnValue = false;
}// 或者直接返回整个事件
document.oncontextmenu = function(){
return false;
}
onselectstart 事件禁用网页上选取的内容
document.onselectstart = function(){
event.returnValue = false;
}// 或者直接返回整个事件
document.onselectstart = function(){
return false;
}
oncopy 事件禁用复制
document.oncopy = function(){
event.returnValue = false;
}// 或者直接返回整个事件
document.oncopy = function(){
return false;
}
以上三种事件,如果只想单纯的禁用鼠标右键,和复制粘贴,还可以将它们直接写到HTML中的body上面
<body oncontextmenu = "return false" ></body>
<body onselectstart = "return false" ></body>
<body oncopy = "return false" ></body>