A detailed explanation of the differences between IE and Firefox in JavaScript

Source: Internet
Author: User

1. When an object is not visible, in IE is not to set its focus, but in Firefox can
2. Append Rows to table:
In the FF, Safari, opera and other browsers, use Document.createelement to create the row with Document.appendchild to add the row directly to the table. But not in IE, and without any error prompts, you need to add the table body (TBODY) to the table, and then add the newly created row to the table body (tbody).
3. ChildNodes different: Firefox to return to the blank as a text node, and IE is not
4. InnerText is the proprietary method of IE, Textcontent is Firefox proprietary, innerHTML is both compatible
5. Set the style class name of a node object.
In IE, the class of a node is set with "ClassName" as the attr to set or get.
Other browsers, such as FF, use "class" as attr to set or get.
6. Event object. IE used EVENTFF with evnt
7. Event Action object. IE used objevent.srcelement,ff with Objevent.target
8,document.form.item problem.
IE in the use of Document.formName.item ("ItemName")
Convert to Document.formname.elements["elementname" in FF
9. Collection class object Use (), IE can accept, MF can not. WORKAROUND: Use [] as subscript operation instead
10,window.event cannot run on FF
11,html the ID of an object as a problem with the object name
Existing problem: In IE, the ID of an HTML object can be used directly as the subordinate object variable name of document. Not in FF.
Workaround: Use getElementById ("Idname") instead of Idname as an object variable
11, the variable name and an HTML object ID the same problem
Existing problem: FF, the object ID is not the name of the HTML object, so you can use the same variable name as the HTML object ID, IE cannot
Solution: When declaring variables, all add Var, in order to avoid ambiguity, so that in IE can also be normal operation. Also, it is best not to take variable names that are the same as the HTML object IDs to reduce errors
12,event.x and EVENT.Y problems
Existing problem: In IE, the event object has an X, y attribute, which is not in FF.
Workaround:
In FF, the equivalent to Event.x is Event.pagex. But Event.pagex ie did not.
Therefore, the use of Event.clientx instead of event.x. This variable is also available in IE.
There are subtle differences between Event.clientx and Event.pagex (when the entire page has a scroll bar), but most of the time it is equivalent.
If you want to be exactly the same, you can be a little more troublesome: MX = event.x? Event.x:event.pagex and then use MX instead of event.x.
13, the problem of the parent node
There is no parentelement Parement.children in FF with ParentNode Parentnode.childnodes. ChildNodes the meaning of the subscript is different in IE and FF, FF uses the DOM specification, and a blank text node is inserted in ChildNodes. It is generally possible to avoid this problem by Node.getelementsbytagname ().
14,const problem
Existing problem: The Const keyword cannot be used in IE. such as const CONSTVAR = 32; This is a syntax error in IE.
Workaround: Do not use const instead of Var.
15,body objects
The body of the FF body tag is not fully read by the browser before the existence, and IE must be completely read in the body after the existence of
16,nodename and TagName issues
Existing problem: In FF, all nodes have nodenaqme values, but textnode do not have tagName values. In IE, the use of nodename seems to be problematic.
Workaround: Use TagName, but check to see if it is empty
17, Element attributes
IE under the Input.type property is read-only, but can be modified under FF
18,document.getelementsbyname () and document.all[name] problems
Existing problem: In IE, Getelementsbyname (), Document.all[name] can not be used to obtain the DIV element (whether there are other elements that cannot be taken is unknown).
19, the treatment of spaces. According to the HTML standard, the space character is  . In FF, if you mistakenly write &nbsp (a semicolon missing), you will not be considered a space by Firefox, Firefox will think it is &nbsp. In IE, if you mistakenly write &nbsp (a semicolon less) ie intelligently thinks it is a space.
20, the processing of the annotation.
According to the HTML standard, the annotation operation is placed between the <!--and-->, and cannot have--otherwise, an HTML parsing error is generated.

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.