Browser version compatibility (Advice)

Browser upgrades are not always upwardly compatible.

It is fairly obvious that as browsers are improved, new features will be added. This suggests that you might upgrade and begin to exploit those new features. At the next browser upgrade, these features should still be available, while yet more are introduced. This is called upwards compatibility. This is generally no problem.

Downwards compatibility, where code using features in a later browser does not cause errors in an earlier browser, is a little more difficult to provide. HTML has good downwards compatibility due mainly to the fact that if a tag is unrecognized, it is simply ignored. That means web pages containing new features simply display any contained text inside the unrecognized block as if the unsupported tag did not exist.

This may be easy to manage with HTML, but is not feasible with a scripting language because you can't expect the browser simply not to execute a line of script. However, you can code defensively in such a way that your scripts may be downwards compatible.

Coding defensively means to check for the existence of a feature before using it, and also to check that objects are defined before trying to modify their properties. You can check the version of the browser and switch various features of your scripts on and off accordingly.

With a little thought and planning, you can design your script so that it degrades gracefully if it is run on less capable browser versions than that which you originally designed it for.

The differences between browsers are now so complex and so diverse that it is difficult to encompass them all in a single reference source. This book is structured to allow it to be revised on a component-by-component basis so that where browsers differ from one another, the granularity of the book is approximately the same and can track those differences as they become known.

The differences between the browsers may change in very subtle ways even with minor browser version changes. We concentrate on the differences between major versions and use annotations to cover important differences between minor browser versions.

Any feedback or observations you care to submit will be welcomed, tested, and added to the future editions of the book.

Good workaround techniques involve innovative use of scripts to create your own properties and methods to emulate missing functionality. For example, the window.opener property is not available on all versions of Netscape. You could create a property of your own that refers to the parent window when a new window object is created. If that property is always present and created under script control, then you can use that property rather than the one that may or may not be present in the built-in object model. This is generally more robust, but may not exploit the very latest features of the available browsers.

See also:Compatibility, Date object, Defensive coding, Internet Explorer, Window.opener