Here are some of the things I've encountered in development:
1, delete a row in the table dynamically.
Table: Represents a Table object.
K: Indicates line number
Table.rows[k].removenode (TRUE); Firefox execution failed, ie executed successfully
IE and Firefox compatibility
Table.deleterow (k);
2, custom attributes for HTML tags.
Inputelement: Represents a FORM element.
PropertyName: Represents a property under a FORM element
Inputelement.propertyname; Firefox execution failed, ie executed successfully
IE and Firefox compatibility
document.getElementById ("Txtinput"). attributes["Idvalue"].nodevalue
3. Inserts an HTML element at the specified location.
Inputelement: Represents a FORM element.
Vdiv: Represents the HTML element that will be inserted.
Inputelement.insertadjacentelement ("Afterend", Vdiv)//firefox execution failed, ie executed successfully
IE and Firefox compatibility
In Firefox, there is no definition of the method, so if you need to call the method, you need to redefine the method yourself.
Copy Code code as follows:
Overriding the Insertadjacentelement () method because there is no such method in Firefox
Htmlelement.prototype.insertadjacentelement=function (Where,parsednode) {
Switch (where) {
Case "Beforebegin":
This.parentNode.insertBefore (Parsednode,this);
Break
Case "Afterbegin":
This.insertbefore (Parsednode,this.firstchild);
Break
Case "BeforeEnd":
This.appendchild (Parsednode);
Break
Case "Afterend":
if (this.nextsibling)
This.parentNode.insertBefore (parsednode,this.nextsibling);
Else
This.parentNode.appendChild (Parsednode);
Break
}
}
4, break statement failure.
When executing a For loop statement in IE, the break can be used to jump out of the secondary loop. But in FF it becomes the exit of the entire loop. Instead, use the Continue statement.
5, Firefox newspaper string contains an invalid character.
var chkbox=document.createelement (' <input type= checkbox ' name= ' Treebox ' value= ' +key+ ' > '); Successful execution under IE
IE and Firefox compatibility
Firefox does not support this createelement definition, and needs to be done in a step-by-step manner:
Copy Code code as follows:
var chkbox = document.createelement (' input ');
Chkbox.name = "Treebox";
Chkbox.type = "checkbox";
Chkbox.value = key;
6. A collection of (table row) objects for a Table object
Bdlist.rows (k). Cells (0). InnerHTML = "<a>aaa</a>";//firefox execution failed, ie executed successfully
IE and Firefox compatibility
Copy Code code as follows:
bdlist.rows[k].cells[0].innerhtml = "<a>aaa</a>";
7, JS getyear () method in the Firefox problem
var today = new Date ();
var year = Today.getyear ();
Inside Firefox getyear Returns the value of "Current year-1900" inside IE:
When today's year is less than 2000, it's the same as Firefox. So it's best to use getFullYear getutcfullyear to call
IE and Firefox compatibility
Copy Code code as follows:
var today = new Date ();
var year = Today.getfullyear ();