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.