Question about textNode sharding in FireFox _ javascript skills

Source: Internet
Author: User
TextNode fragment in FireFox. A common behavior in Ajax applications is to wrap data in XML in the background and return it to the browser. The browser parses XML to obtain nodeValue.

If the content of a single node is long (more than 4096 bytes), you should note that the content will be divided into multiple textnodes by FrieFox, each of which is 4096 bytes. In this case, the following functions can be used for processing (IE compatibility)

The Code is as follows:


Function getNodeValue (node)
{
If (node & node. hasChildNodes ()){
// Return node. firstChild. nodeValue;
Var s = ""
// Mozilla has extends textnodes with a size of 4096
// Chars each instead of one large one.
// They all need to be concatenated.
For (var j = 0; j S + = new String (node. childNodes. item (j). nodeValue );
}
Return s;
} Else
Return "";
}

Related Article

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.