How to get/retrieve context menu value after right click with Javascript?

纵然是瞬间 提交于 2019-12-02 11:58:04

问题


I can't find a related question to give me an idea about how to do this.

I've seen some topics about how to know if the right-click button was clicked but I'd like to be able to capture the value that's selected on a context menu after right click.

Any idea how I could achieve it?


回答1:


In a browser, you can:

a) ignore the right click and let the browser itself handle it (which usually means a context menu will be shown)

XOR

b) handle the right click yourself, which means that the browser won't show its context menu.

You can't have both a) and b), they're mutually exclusive. If you want a right-click context menu on a webpage, you need to fake it yourself - for example, see this tutorial and the result.



来源:https://stackoverflow.com/questions/9600420/how-to-get-retrieve-context-menu-value-after-right-click-with-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!