禁用/启用右键单击html正文的特定部分 [英] disable/enable right click on a particular part of the html body

查看:47
本文介绍了禁用/启用右键单击html正文的特定部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在网页上禁用右键单击,但是我想在textarea上启用右键单击.嘿w是提供答案的地方,不要在右键单击时发布很多评论(笑).我不在乎人们是否会看到我的源代码,这不是重点……我只想知道一个人如何仅在文本区域中启用右键单击而禁用其余部分

i want to disable right click on the webpage but i want enable right click on textarea. Hey wat is this provide answers dont post lot of comments on right click (lol). i dont care if people would see my source code, thats nt the point ... i just want to know how one can enable right click only in the textarea while disabling the rest

所以any1在这里知道将执行此工作的javascript函数??

so any1 here know the javascript function that would perform the job ??

下面的代码可能吗??

is the below code possible ??

<html>
<head>
<title>  Your Title  </title>
</head>
<body oncontextmenu="return false;">
<textarea  oncontextmenu="return true;">


</textarea>
</body>
</html>

-预先感谢

-miss subanki

-miss subanki

推荐答案

要在主体上的特定元素上启用右键单击,同时在主体的其余部分上禁用右键单击(使用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.

这篇关于禁用/启用右键单击html正文的特定部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆