A simple implementation of cross-browser webpage context menu, cross-browser context menu
This article describes how to implement the right-click menu and cross-browser context menu.
In general, right-click a webpage (this is in windows, while in MAC), and the default menu is displayed. to display a custom right-click menu, you need to cancel the default browser behavior and display the custom menu. Let's take a look at an event: a contextmenu event, that is, a context menu event. in windows95, we first introduced the context menu concept. Soon this concept was gradually introduced into the web field. This event can solve the problem of canceling the display of the default menu and display the custom menu. This event is bubbling, you can use document to process this event. The so-called event bubbling means that the event will gradually spread from where the event occurs, Some browsers can spread to Windows, and some can only spread to document. Browsers that support this event include ie, firefox, safari, chrome, and opera10 +. To handle browsers that do not support this event, the following code is provided:
<! DOCTYPE html>