JavaScript browser compatibility summary and Common Browser compatibility analysis _ javascript skills

Source: Internet
Author: User
This article is a daily summary of some js compatibility issues and Compatibility Analysis of IE and Firefox and other common browsers, if you are interested in js browser compatibility, learn it together. This article is a daily summary of js compatibility issues and Compatibility Analysis of IE and Firefox and other commonly used browsers, if you are interested in js browser compatibility, join us!

1. children and childNodes

The behaviors of children, childNodes and childNodes in firefox provided by IE are different. In firefox, childNodes counts line breaks and blank characters as child nodes of the parent node, but IE's childNodes and children won't. For example:

yizhu2000

P whose d is dd can be viewed in childNodes in IE. The number of subnodes is 1, and the number of subnodes in ff is 3, we can see from the dom viewer of firefox that its childNodes is ["\ n", p, "\ n"].

To simulate the children attribute in firefox, we can do this:

if (typeof(HTMLElement) != "undefined" && !window.opera) {HTMLElement.prototype.__defineGetter__("children", function() {for (var a = [], j = 0, n, i = 0; i < this.childNodes.length; i++) {n = this.childNodes[i];if (n.nodeType == 1) {a[j++] = n;if (n.name) {if (!a[n.name])a[n.name] = [];a[n.name][a[n.name].length] = n;}if (n.id)a[n.id] = n;}}return a;});} 

2. firefox and ie events

Window. event can only be used in IE, but not in Firefox, because Firefox event can only be used in the event. Firefox must be added to the source for parameter transfer. IE ignores this parameter and uses window. event to read this event.

For example, the following method is used to obtain the mouse position under ie:

Obtain the abscissa of mouse clicks

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.