Example Analysis of Javascript compatibility in IE and Firefox
This article mainly introduces the example analysis of Javascript compatibility in IE and Firefox, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
As JavaScript compatibility has been a major issue for Web developers for a long time, this article describes the summary of Javascript compatibility between IE and Firefox, including five aspects: differences in functions and methods, style access and settings, DOM methods and object references.
Summary of Javascript compatibility between IE and Firefox
JavaScript compatibility has long been a major issue for Web developers. The differences between formal specifications, de facto standards, and various implementations afflict many developers day and night. For this reason, the Javascript compatibility of IE and Firefox is summarized from the following aspects:
I. differences in functions and methods
II. Style access and setting
Third, DOM method and object reference
IV. Event handling
Fifth, the compatible treatment of other differences.
I. differences in functions and methods
1.getYear () method
[analysis instructions] first take a look at the following code:
Viewsourceprint?
1varyear=newDate () .getYear (); [xss_clean] (year)
The date you get in IE is "2010", and the date you see in Firefox is "110", mainly because getYear returns the value of" current year-1900 "in Firefox.
[compatible processing]
Plus the judgment of the year, such as:
Viewsourceprint?
1varyear=newDate (). GetYear (); year= (year