The following is what I encountered in development:
1. Dynamically delete a line in Table.
Table: Indicates Table objects.
K: Represents line number
table.rows [k] .removenode (true); // Firefox's execution failed, IE execution was successful
IE and Firefox compatible writing
table.deleterow (k);
2. Customized attributes for HTML tags.
Inputlement: Represents the table unit element.
PropertyName: Represents a certain attribute under the table element
InputElement.propertyName; // Firefox's execution fails, IE execution is successful
IE and Firefox compatible writing
document.GetelementByid ("TXTINPUT"). Attributes ["IDValue"]. Nodevalue
3. Insert HTML elements at the specified location.
Inputlement: Represents the table unit element.
VDIV: It means the HTML element to be inserted.
Inputlement.insertadjaCentelement ("Afternd", VDIV; // Firefox execution fails, IE execution is successful, successful execution
IE and Firefox compatible writing
In Firefox, there is no definition of this method. Therefore, if you need to call this method, you need to define this method yourself.
Copy code code as follows:
// Rewrite the INSERTADJACENTELEMENT () method, because there is no method in Firefox
Htmlement.prototype.insertadjaCentelement = Function (where, PAREDNODE) {
switch (where) {
Case "Beforebegin":
this.parentnode.insertBeface (PARSEDNODE, this);
Break;
Case "Afterbegin":
this.insertBeFore (PARSEDNODE, this.firstChild);
Break;
Case "Beforend":
This.appendchild (PARSEDNODE);
Break;
Case "Afternd":
if (this.nextSING)
this.parentnode.insertBeFore (PARSEDNODE, this.nextSIBling);
else
this.parentNode.appendchild (PARSEDNODE);
Break;
}
}
4. Break statement failure.
When performing the for loop statement in IE, the use of BREAK can jump out of the cycle. But in FF, it becomes exit the entire cycle. At this time, use the Continue statement.
5. Firefox reports String Contains An Invalid Character.
var chkbox = document.createElement ('<input type = "Checkbox" name = "timeBox" value ='+key+'>'); // Successfully execute under IE
IE and Firefox compatible writing
Firefox does not support the definition of this CreateElement and needs to be carried out step by step:
Copy code code as follows:
var chkbox = docment.createelement ('input');
chkbox.name = "Treebox";
chkbox.type = "Checkbox";
chkbox.value = key;
6. The collection of the Table object (table line) object
bdlist.rows (k) .Cells (0) .innerhtml = "<a> AAA </a>"; // Firefox's execution failed, IE execution was successful successfully
IE and Firefox compatible writing
Copy code code as follows:
bdlist.rows [k] .Cells [0] .innerhtml = "<a> AAA </a>";
7. The problem of JS's getyear () method in Firefox
var today = new date ();
var years = today.getyear ();
In Firefox, Getyear returns the value of "Current Year-1900" value IE:
When the year of TODAY is less than 2000, it is the same as Firefox. Therefore
IE and Firefox compatible writing
Copy code code as follows:
var today = new date ();
var Year = today.getfullyear ();