Dom compatibility with browsers

Source: Internet
Author: User

If you do not know about Dom or the role of Dom, read: What is Dom?
As a Web Front-end worker, are you often confused by browser compatibility issues, such as CSS styles? All normal Web pages are displayed in IE. in Firefox or Google browser, it is a mess. you may have encountered similar problems when writing web scripts using JavaScript and Dom. the script runs normally in the Firefox browser. an error occurs in IE. for example, obtain the source target that triggers the JS event. there are also mouse or element positions. dynamically bind events to elements... I will list some Dom commands below for incompatibility issues in IE, Firefox, and other browsers!
Limited length. I will not explain the DOM commands mentioned on this page in detail. Please click the relevant command name for detailed explanation and examples.
When Javascript is used to obtain the source target of the trigger event, ie is different from Firefox, that is, the element in the webpage triggers the event.

    1. Use srcelement in IE browser
    2. Use target in Firefox

How to Use Dom to retrieve and change text in Webpage tag Elements

    1. Use innertext in IE
    2. Use textcontent in Firefox

Place the cursor inside the element

    1. In IE, offsetx and offsety are used to obtain the location of an element on the webpage.
    2. Firefox uses layerx and layery to obtain the location of an element in the webpage.

Dynamically binding and deleting events to webpages or elements

    1. The method for binding events in IE is attachevent.
    2. Detachevent is used to delete binding events in IE.
    3. The method for binding events in Firefox is addeventlistener.
    4. The removeeventlistener method is used to delete binding events in Firefox.

To be continued... Kang Dong Yu: 2010-08-12

 

 

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.