在这种情况下如何重新启用上下文菜单?
document.addEventListener('contextmenu', function (e) {
e.preventDefault()
e.stopPropagation()
e.returnValue = false
e.cancleBubble = true
})
决不?
编辑: document.oncontextmenu = null
不起作用。
PS 我无法获得侦听器功能的参考,因为我不是阻止上下文菜单的站点的所有者。
document.addEventListener('contextmenu', function (e) {
e.preventDefault()
e.stopPropagation()
e.returnValue = false
e.cancleBubble = true
})
No way?
Edit: document.oncontextmenu = null
does not work.
P.S. I cannot have the reference of the listener function since I am not the owner of the site preventing the context menu.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在这种情况下我使用我的书签:
I use my bookmarklet in such cases:
如果您真的绝望,请尝试在调用
addEventListener
之前添加此内容。它适用于 FF 和 Chrome。我没有检查其他任何东西。这可能不是最好的做事方式,但它应该是针对您的具体示例完成的工作:)
If you are really desperate, try adding this before the
addEventListener
is called. It works in both FF and Chrome. I didn't check anything else.It may not be the best way to do things, but it should be the job done on your specific example :)
为什么不分配右键单击事件而不是禁用上下文菜单呢?
http://abeautifulsite.net/2008/05/jquery-right-click -插件/
Rather than disabling the context menu, why don't you assign the right click event?
http://abeautifulsite.net/2008/05/jquery-right-click-plugin/