Firefox handles childNodes by using the tab function on msn _ navigation menu

Source: Internet
Author: User
Today, the company used a tab function to find that msn is good, but it is not compatible with firefox. their msn method is to use a lot of div inclusion, but there are some people on the Internet to solve it. A bug in Firefox's childNodes processing
ChildNodesFirefox does not filter line breaks and spaces when processing childNodes. Therefore, the first time you use it, the expected results are not.
HTML

The code is as follows:



  • Financial management university B

  • Medical Lecture Hall

  • Medical Lecture Hall

  • Medical Lecture Hall

  • Film hotspot



JS

The code is as follows:


Function tabit (btn)
{
Var idname = new String (btn. id );
Var s = idname. indexOf ("_");
Var e = idname. lastIndexOf ("_") + 1;
Var tabName = idname. substr (0, s );
Var id = parseInt (idname. substr (e, 1 ));
Var tabNumber = btn. parentNode. childNodes. length; // the values of IE and FF are different.
For (I = 0; I {
If (document. getElementById (tabName + "_ p _" + I )! = Null) // you need to determine
{
Document. getElementById (tabName + "_ p _" + I). style. display = "none ";
Document. getElementById (tabName + "_ btn _" + I). style. backgroundImage = "url (pic/t-1-2.gif )";
Document. getElementById (tabName + "_ btn _" + I). style. borderBottomColor = "# D7F2DA ";
Document. getElementById (tabName + "_ btn _" + I). style. cursor = "pointer ";
}
}
Document. getElementById (tabName + "_ p _" + id). style. display = "block ";
Btn. style. backgroundColor = "# fff ";
Btn. style. borderBottomColor = "# fff ";
Btn. style. cursor = "default ";
}


On IE, the value of childNodes. length of menuList is 5, and the value of Firefox is 11. Therefore, when using the childNodes object, we need to judge it first or remove spaces.

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.