A summary of the modification of FF IE compatibility _javascript tips

Source: Internet
Author: User
1.html tags If you use the $ (ID) or getElementById to value the two methods, you want to add the ID of the tag attribute, IE, FF compatible. such as $ (mobile): If you fill in Mobile input no id attribute in FF will report this variable undefined;
2. Take a form of a Label object, if you want IE, FF compatible to the Formmain.item to Document.formName.item.
If Form1.weburl changed to DOCUMENT.FORM1.WEBURL.
If the form is passed to a function as a parameter, add "document.", such as search (FormMain) instead of search (Document.formmain)
3. The custom attribute of fetching HTML is changed to Obj.getattribute ("AttributeName") by Obj.attributename, IE, FF compatible; Non-custom attributes can still follow
Obj.attributename take.
such as: <input type= "text" name= "MEMBERCN" checkvalue= "notnull;elength:25" > The CheckValue attribute in this label is a custom attribute, Obj.getattribute ("CheckValue"), IE, FF is compatible, other properties such as the Type property can still be used to take the Obj.type
4.eval functions, which are not used in FF and IE, can not be executed in IE if an executable statement connected with "+" in FF is taken as an eval parameter. When you encounter an eval, try to find another way to replace it.
such as: eval ("Msg_" + textbox.name+ ". Classname= ' wrong ');
"Msg_" + textbox.name+ ". Classname= ' wrong ' as an eval parameter in IE can be executed, in FF executive times" Msg_ "+ textbox.name connection to get the space name undefined, Cannot execute, to be modified to:
document.getElementById ("Msg_" + textbox.name). Classname= ' wrong ';
5. The attribute block of display in the style, which can be empty if an exception is encountered in FF, such as item.style.display= "block" can be changed to item.style.display= ""
such as $ ("DivType4"). style.display= "Block";
Instead of $ ("DivType4"). style.display= "";
6. Add another: label in FF seems to be different from IE: for example, the following code:
&LT;TD colspan = "3" class = "line_l" > Adult <label>
<input name = "Amount" type = "text" value = "${amount}" size = "6" maxlength = "Elename =" [Adult reservation number] "CheckValue = "Notnull;elength:10;islong"/>
Human children
<input name = "Kidamount" type = "text" value = "${kidamount}" size = "6" maxlength = "Elename =" [Children book Number] "Chec Kvalue = "Notnull;elength:10;islong"/>
Human <span class = "line_red" > * </span></label>
</td>
The child's cursor always goes to the adult when the input is written in FF, IE does not, and this does not:
<td width = "25%" > Adult <label>
<input name = "Amount" type = "text" value = "${amount}" size = "6" maxlength = "Elename =" [Adult reservation number] "CheckValue = "Notnull;elength:10;islong"/> People </label></td>
<td width = "75%" > Child <label><input name = "Kidamount" type = "text" value = "${kidamount}" size = "6" max Length = "Elename =" [Children book number] "CheckValue =" Notnull;elength:10;islong "/> Person </label></
Note the position of the label, one is outside the two input, one is outside of an input,
Does the label label not contain two input labels in FF???
There is another place: The code is as follows:
<td><label>
<select name = "Provinceid" id = "Provinceid" onchange = "inicity" (Document.frmMain.provinceId, document.frmmain.cityid,document.frmmain.subcity); "Elename =" [in the province] "CheckValue =" Is_long ">
</Select> Province
<select name = "Cityid" id = "Cityid" onchange = "inisubcity" (Document.frmmain.provinceid,document.frmmain.cityid, document.frmMain.subCity); "Elename =" [The city] "CheckValue =" Is_long "></select> City
<select name = "Subcity" id = "Subcity" elename = "[County area]" CheckValue = "Is_long" ></select>
<span class = "Red" > * </span></label></td>
This code, the second, the third select cursor will not hold, should be run to the first select, but because it is a select so cannot see, but the above input can be seen. The same problem is normal in IE. I think this also explains what I said above.

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.