Difference between Ie and Firefox (JavaScript)

Source: Internet
Author: User

1. When an object is invisible, you cannot set its focus in IE, but in Firefox, you can
2. append rows to a Table:
In FF, Safari, Opera, and other browsers, use document. createElement to create a row and then use document. appendChild to add the row directly to the table. However, it is not allowed in IE and there is no error message. In this case, you need to add the table body (tbody) and then add the newly created rows to the table body (tbody ),
3. childNodes: Firefox regards the blank space after the carriage return as a text node, While ie is not
4. innerText is the proprietary method of IE, textContent is the proprietary method of Firefox, and innerHTML is both compatible.
5. Set the style class Name of a node object.
In ie, set the class of a node to "className" as attr to set or get.
Ff and other browsers use "class" as attr to set or get.
6. event object. Use evnt with eventff for ie
7. Event action object. Ieuses objevent.srcelement, and ffuses objevent.tar get
8. document. form. item.
Document. formName. item ("itemName") in ie ")
Use document. formName. elements ["elementName"] in ff.
9. Use () when using a collection class object, IE can accept, MF cannot. Solution: use [] as the subscript.
10. window. event cannot be run on fF.
11. Question about the id of an HTML object as the object name
Existing Problem: in IE, the ID of the HTML object can be directly used as the variable name of the subordinate object of the document. It cannot be in fF.
Solution: Use getElementById ("idName") instead of idName as the object variable.
11. The variable name is the same as the id of an HTML object.
Existing Problem: In 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, which cannot be
Solution: When declaring variables, add var to avoid ambiguity, so that it can run normally in IE. In addition, it is best not to take the same variable name as the HTML Object id to reduce errors.
12. event. x and event. y
Existing Problem: in IE, the event object has the x, y attributes, and fF attributes.
In fF, event. x is equivalent to event. pageX. But event. pageX IE does not.
Therefore, event. clientX is used instead of event. x. This variable is also available in IE.
Event. clientX is slightly different from event. pageX (when the page has a scroll bar), but most of the time it is equivalent.
If it is the same, it may be a little troublesome: mX = event. x? Event. x: event. pageX; then use mX instead of event. x
13. parent node Problems
In ff, parentElement parement. children is used instead of parentNode. childNodes. ChildNodes has different meanings in IE and fF. fF inserts blank text nodes in childNodes using DOM standards. You can avoid this problem by using node. getElementsByTagName.
14. const Problems
Existing Problem: you cannot use the const keyword in IE. For example, const constVar = 32; in IE, This Is A syntax error.
Solution: use var instead of const.
15. body object
FF's body exists before the body tag is fully read by the browser, While IE exists only after the body is fully read.
16. nodeName and tagName Problems
Existing Problem: In ff, all nodes have a nodeName value, but textNode does not have a tagName value. In IE, nodeName usage seems to be faulty.
Solution: Use tagName, but check whether it is empty.
17. Element attributes
The input. type attribute in IE is read-only, but can be modified in ff.
18. document. getElementsByName () and document. all [name] Problems
Existing problems: in IE, getElementsByName () and document. all [name] cannot be used to obtain div elements (whether there are other elements that cannot be retrieved is unknown ).
19. Processing of space characters. According to the HTML standard, the space character is & nbsp ;. In ff, If you mistakenly write & nbsp (with a semicolon missing), FireFox will not regard it as a space, and FireFox will regard it as & nbsp. In IE, If you mistakenly write & nbsp (with a semicolon missing), IE may think it is a space.
20. process the annotation.
According to the HTML standard, the Comment operation is placed in <! -- And -->, and the annotation cannot contain --; otherwise, an HTML parsing error occurs.

Related Article

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.