且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

禁用/启用右键单击html正文的特定部分

更新时间:2021-09-28 22:03:27

要在主体上的特定元素上启用右键单击,同时在主体的其余部分上禁用右键单击(使用html),则必须将iframe中需要的元素(要启用鼠标右键).然后禁用对主体的右键单击.

To enable right click on a particular element on the body while disabling the right click on the rest of the body (in html), you wil have to put the required element (whose right click you want to enable) into an iframe. And disable the right click on main body like this....

主体

<html>
<head>
<title>Your Title</title>
</head>
<body  oncontextmenu="return false;">
<iframe src="frame1.html">
</iframe>
</body>
</html>

frame1.html

frame1.html

<html>
<body>
<textarea> Your text, u can right click here </textarea>
</body>
</html>

如果其他人有更好的答案,请在此发布,而不是所有人.

if anyone else has a better answer please post it here, thanx everyone.