.
3ss.cn

html怎么禁止右键

html禁止右键方法:1、使用oncontextmenu事件,禁用鼠标右键的菜单;2、使用onselectstart事件,禁止利用右键在网页上选取内容;3、使用oncopy事件,禁止利用右键进行复制。

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

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;
}
<body oncontextmenu = "return false" ></body>
<body onselectstart = "return false" ></body>
<body oncopy = "return false" ></body>
赞(0)
未经允许不得转载:互联学术 » html怎么禁止右键

评论 抢沙发