13.4 Compatibility and Interoperability
The web platform is always evolving and expanding. A standards body proposes a new feature or API. If the feature seems useful, browser vendors implement it. If enough vendors implement it interoperably, developers begin to use and depend on the feature, and it secures a permanent place in the web platform. Sometimes browser vendors and web developers take the lead and standards bodies write the official version well after the feature is already a de facto standard. In either case, a new feature has been added to the Web. New browsers support it and old browsers do not. Web developers are pulled between wanting to use powerful new features and wanting their web pages to be usable by the largest number of visitors—even those who are not using the latest browsers.
Sometimes browser vendors differ in their opinions of whether a particular feature is useful enough to implement. Some vendors implement it and others do not. This is not a matter of current browsers with the feature versus older browsers without it, but a matter of browser implementors who prioritized the feature versus those who did not. IE8, for example, does not support theelement, though all other browsers have embraced it. A more egregious example is Microsoft’s decision not to implement the DOM Level 2 Events specification (which defines addEventListener() and related methods). This specification was standardized almost a decade ago, and other browser vendors have long since supported it.3
3. To Microsoft’s credit, IE9 now supports both theelement and the addEventListener() method.
13.4 Compatibility and Interoperability | 325
implementing ES5. The transition between ES3 and ES5 may be the source of compatibility problems, because some browsers will support strict mode while others do not, but the expectation is that browser vendors will implement ES5 interoperably.
The Mozilla Developer Center
The Microsoft Developer Network
The Safari Dev Center at the Apple Developer Connection
A Wikipedia article tracking the implementation status of HTML5 features and APIs in various browsers.
A similar article that tracks the implementation status of DOM features.
The “When can I use...” website tracks the implementation status of important web features, allows them to be filtered according to various criteria, and recommends their use once there are few remaining deployed browsers that do not support the feature.
Tables that list the compatibility of various browsers with the W3C DOM.
Another site that attempts to track the implementation of web standards by browser vendors.
Awareness of the incompatibilities between browsers is only the first step, of course. Next, you must decide how to address the incompatibilities. One strategy is to restrict yourself to using only those features that are universally supported (or easily emulated) by all of the browsers that you choose to support. The “When can I use...” website mentioned previously ( http://a.deveria.com/caniuse ) is based around this strategy: it lists a number of features that will become usable as soon as IE6 has been phased out and no longer has a significant market share. The subsections that follow explain a few less passive strategies you can use to work around client-side incompatibilities.
A Word about “Current Browsers”
- Internet Explorer 8
- Firefox 3.6
- Safari 5
- Chrome 5
- Opera 10.10
When this book reaches bookstores, the current browsers will likely be Internet Explorer 9, Firefox 4, Safari 5, Chrome 11, and Opera 11.
This is not a guarantee that every statement in this book about “current browsers” is true for each of these specific browsers. However, it allows you to know what browsers were current technology when this book was written.
The fifth edition of this book used the phrase “modern browsers” instead of “current browsers.” That edition was published in 2006, when the current browsers were Firefox 1.5, IE6, Safari 2, and Opera 8.5 (the Chrome browser from Google did not exist yet). Any references to “modern browsers” remaining in this book can now be taken to mean “all browsers,” since browsers older than those are now quite rare.
Many of the newest client-side features described in this book (in Chapter 22 particularly) are not yet implemented by all browsers. The features that I’ve chosen to document in this edition are being developed under an open standards process, have been implemented in at least one released browser, are under development in at least one more, and seem likely to be adopted by all browser vendors (with the possible exception of Microsoft).
13.4 Compatibility and Interoperability | 327欢迎转载,转载请注明来自一手册:http://yishouce.com/book/1/27701.html