Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
290 views
in Technique[技术] by (71.8m points)

如何解绑html标签内直接绑定的事件

是这样的情况,有个网页在body上绑定了禁止选中禁止右键的事件,我想用js解除这个事件,该如何做呢?

<body 
    oncontextmenu="return false;"
    onselectstart="return false;"
>
    ...
</body>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

1 Answer

0 votes
by (71.8m points)
document.body.setAttribute("oncontextmenu","");
document.body.setAttribute("onselectstart","");

置空就行了


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
...