A simple implementation of cross-browser webpage context menu, cross-browser context menu

Source: Internet
Author: User

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> 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.