JavaScript and Browser Compatibility

[ LiB ]

JavaScript and Browser Compatibility

When JScripts are processed by the WSH, browser compatibility issues do not affect JScript programmers.

However, browser compatibility has always been a major issue for JavaScript programmers. The two most popular Internet browsers since the mid-1990s have been Microsoft's Internet Explorer and Netscape's Communicator. Microsoft and Netscape traditionally have had different opinions as to how browsers should work. As a result, Netscape Communicator versions 2, 3, and 4 performed differently in many situations than Internet Explorer versions 3, 4, and 5. HTML pages and JavaScripts often behaved differently when asked to do the same thing on either browser.

One key difference between these earlier versions of Internet Explorer and Netscape Communicator was their object models. Browsers abstract their content and functionality in the form of objects. JavaScript interacts with browsers by interacting with these objects. The problem was that Netscape and Internet Explorer had different object models, so some objects that existed in one browser did not exist in the other. However, with the advent of the ECMAScript standards, things have become a lot more consistent in recent years . As a result, in most circumstances, HTML or JavaScript processed by Netscape Communicator version 6 or 7 should be processed pretty much the same as if it were processed by Internet Explorer 5.5 or 6. However, even with the latest versions of both browsers, small differences in implementation still exist. The only way to be sure that your JavaScripts will behave as expected on both browsers is to test them using both browsers.

Another browser issue that JavaScript programmers still have to be concerned with is what version of JavaScript the various browsers support. JavaScript support began with the Netscape 2 browser, but that browser supports only the initial version of JavaScript. Microsoft began to provide JavaScript support only in Internet Explorer 3. The problem is that there are still a lot of people out there running older versions of both browsers, and trying to accommodate them all is very difficult.

Not all browsers are created equal. In fact, things are made more difficult because Microsoft and Netscape are not the only companies that make browsers. Other browsers provide varying degrees of JavaScript support. For example, the Lynx browser, shown in Figure 1.1, is a simple text-based browser that does not support graphics or JavaScript.

Figure 1.1. The Lynx browser is lightning fast when interacting with Web sites that support text-only content.


One option is to ignore all non-JavaScript browsers and stay with Netscape Navigator and Internet Explorer. You might also write scripts that support only the latest versions of both browsers. This will probably satisfy 98 percent of your potential visitors . However, if you want to attract as many people as possible to your Web site, you may want to consider finding ways to accommodate older browsers. We'll look at different options for dealing with that problem tomorrow.

One other Internet browser that you might want to be on the lookout for it called Opera, pictured in Figure 1.2. It is currently available for trial download at It is less than half the size of its Netscape and Internet Explorer competitors . Still, it provides support for all the features that you'd expect, including support for JavaScript. Best of all, it loads Web pages fast. There is just one catch: It is not free. More and more people are starting to pay attention to it, and you may want to get a copy of it for testing.

Figure 1.2. The Opera Internet browser


[ LiB ]

Learn JavaScript In a Weekend
Learn JavaScript In a Weekend, Second Edition
ISBN: 159200086X
EAN: 2147483647
Year: 2003
Pages: 84 © 2008-2017.
If you may any questions please contact us: