How to add a custom right-click menu to a webpage?

后端 未结 19 1256
广开言路
广开言路 2020-11-22 15:54

I want to add a custom right-click menu to my web application. Can this be done without using any pre-built libraries? If so, how to display a simple custom right-click menu

19条回答
  •  抹茶落季
    2020-11-22 16:30

    
    
    
    
    

    What I'm doing up here

    1. Creat your own custom div menu and set the position: absolute and display:none in case.
    2. Add to the page or element to be clicked the oncontextmenu event.
    3. Cancel the default browser action with return false.
    4. User js to invoke your own actions.

提交回复
热议问题