Nextsibling of Firefox and IE

Source: Internet
Author: User

This article from: http://ailantian.bokee.com/6418694.html

The original article is as follows:

The javascript compatibility between Firefox and IE on the Internet is also much discussed.
Search for "Firefox Javascript compatibility" on Baidu"
Baidu can be used to find Chinese characters on Baidu.
It is generally used for applications such as document. all. It is generally changed to getelementbyid.
In addition, when a page has multiple forms, you need to pay attention to some issues.

The following are some more to be supplemented:
That is, firstchild and nextsbiling.
The function is provided below.CodeComparison
The Code comes from the Internet.
However, getnext and getfirstchild are different.
Next is the next node, which is at the same level and does not obtain its own subnode.

It may be because the understanding of Dom is different. IE and Firefox have different processing methods for firstchild and nextsbiling.
So to get to the next node, you can only use type to determine.

Function getnextsibling (startbrother ){
Endbrother = startbrother. nextsibling;
While (endbrother. nodetype! = 1 ){
Endbrother = endbrother. nextsibling;
}
Return endbrother;
}

Function getnextsibling1 (OBJ ){
If (obj. nextsibling. nodetype = 3 ){
Sibling = obj. nextsibling. nextsibling; // Moz. Opera
}
Else {
Sibling = obj. nextsibling; // IE
}
Return sibling;
}
Function getfirstchild (OBJ ){
For (I = 0; I <obj. childnodes. length; I ++ ){
If (obj. childnodes [I]. nodetype = 1)
Return obj. childnodes [I];
Else
Continue;
}

When you need to use it, first getelementbyid gets the first node, and then you can get the following node.

In addition, ie is case-insensitive. html is formatted first, so the ID may be the same.
May cause some problems.

In addition, ie converts null characters into space spaces, which Firefox will not handle,
If null is processed in Javascript, there may be some problems. Opera is basically compatible with IE.
Functions, such as javasnet. All, can be used. However, null characters are not supported. It is a NULL Character in the variable.
Problems may occur.

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.