Code example: CSS + JavaScript create right-click menu

Source: Internet
Author: User

<% @ Page language = "java" pageEncoding = "GBK" %> <! Doctype html public "-// w3c // dtd html 4.0 transitional // en"> 

Run code Copy code Save code Add to favorites

Code explanation:

1. When loading a page, execute the load1 () method first.

First, check whether it is Internet Explorer. If the current browser is Internet Explorer, document. all returns true. The following definition should be valid. That is to say, when the browser used by the client is IE, the showmenuie5 function is called when the user generates a right-click event. When the user generates a left-click event, the hidemenuie5 function is called.

2. Next we should consider how to display and hide menus through the showmenuie5 function and hidemenuie5 function.

Of course, the menu here is not really a right-click menu, but a div we made ourselves. In this div, We will install what we want to install. You can use the mouse event to call a function to control its explicit and hidden state, which achieves the same effect of using the right mouse button.

The outermost layer of this block is a div with an id of ie5menu. We have defined its style as skin0. You can also customize other styles and then replace skin0.

3. Click the menu option.

The jumptoie5 () function enables you to right-click a layer in the menu, that is, the execution option.

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.