js method distinguishes between IE browser and non IE browser

Source: Internet
Author: User
Tags event listener

Different browsers can be distinguished from ie-specific methods and Non-ie-specific methods

1. Add an event listener for the Element:

non ie:. AddEventListener ("click", show,false)//third parameter for event stream, true for event capture, false for event bubbling

Ie:.attachevent ("onclick", show);

2. To remove an event listener for an element:

non ie:. RemoveEventListener ("click", Show)

Ie:.detachevent ("onclick", show);

3. Stop bubbling

Non-ie:.stoppropagation ()

Ie:.cancelbubble = True '

4. Canceling the event default behavior

Non-ie:.preventdefault ()

Ie:.returnvalue = false;

5. Get values for Non-inline styles and inline styles

Non-IE:window.getComputedStyle (document.get....,null)//the First value is the acquired element, the second value is a pseudo-class, and null means no Pseudo-class

IE:document.getElementById ("xx"). Currentstyle

js method distinguishes between IE browser and non IE browser

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.