JavaScript 右键弹出窗口
是否可以检查上下文菜单是否可见(即用户单击鼠标右键后),如果可见,则再次隐藏它? (使用Javascript)
我将尝试在发生一系列事件后隐藏它,这样用户就不会无法右键单击打开上下文菜单。 (所以没什么黑客:p)
编辑:这应该是场景(插件的一部分):
*用户双击鼠标右键两次
->我捕获该事件并关闭当前选项卡
* 如果用户使用 Linux,有时会弹出上下文菜单(浏览器之一:后退、前进、另存为...)
->如果上下文菜单可见,则再次隐藏它(请参阅上面的步骤)
Is it possible to check if the context menu is visible (ie. after a user has clicked the right mouse button), and if visible, to hide it again ? (with Javascript)
I'm going to try to hide it after a series of events have happened, so it won't be the case the user will be not able to right-click to open the context menu. (so nothing hacky :p)
EDIT: this should be the scenario (part of an addon):
* user double clicks with right mouse button twice
-> i catch the event and close the current tab
* if the user has Linux sometimes the context menu pops up (the one of the browser with: Back, Forward, Save As,...)
-> hide the context menu again if it's visible (see step above this one)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是完全不可能的。
你想做什么?
This is completely impossible.
What are you trying to do?
具体是怎样的场景?从问题来看不太清楚。这是否涉及实际的浏览器上下文菜单或您自己的覆盖常规菜单的自定义上下文菜单?对于浏览器,我认为不可以,但对于自定义浏览器,我不明白为什么不。您可以为此连接自己的自定义跟踪标志。
考虑是否可以覆盖原始上下文菜单,在两次右键单击之间进行自己的计算(以模拟右键双击),如果间隔太长,请使用javascript显示上下文菜单,但作为我在下面评论说,这看起来不可能。
我想如果你不能从 javacript 做相反的事情,那么相反的事情也将成立,这意味着你可能无法做到这一点。
What exactly is the scenario? Not too clear from the question. Does this involve the actual browser context menu or your own custom context menu that override the regular one? For browser I'd think no, but for custom one, I don't see why not. You can wire in your own custom tracking flag for this.
Thinking if it is possible to just override the original context menu, do your own calculation between the 2 right-clicks (to simulate right-button double click) and if the interval is too long, use javascript to show the context menu, but as I commented below, that does not look possible.
I'd imagine that if you can't do the opposite from javacript, then the oppossite of that will also be true, meaning you probably can't do this.