简体   繁体   中英

Javascript right click popup

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)

This is completely impossible.
What are you trying to do?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM