Back to the Web Developer's Journal Main Page
internet.com
side nav bar

Keywords
More articles by Andrew Starling:

HOW DID THEY DO THAT???

Find out in:
Amazing HTML



Site Map

Jobs at webdeveloper.com


Discussion:

Check out and join our email-based Mailing Lists for Web developers.


Developer Channel
FlashKit
Jobs.webdeveloper
JavaScript.com
JavaScriptSource
JustSMIL
ScriptSearch
Streaming Media World
WebDeveloper.com
WebReference
XMLFiles
WDVL
Discussion Groups Book Reviews Software Reviews Download Web Tools

Far Better Than Beta

Netscape 6: Updating Your JavaScript

by Andrew Starling

How much of your site's JavaScript do you need to change so it can be read by Netscape 6? Happily, only the complicated bits. Most simple JavaScript works in the new browser. But if you have scripts with separate lines for IE and NN, you'll need to update these. Here's a guide to recognising how much extra work the new browser has saddled you with.
December 6, 2000

Let's start with a round of applause for Netscape. Back in June I reviewed the first beta release of the new browser and gave it a resounding thumbs-down. Chances were, it seemed, the final release would suck louder than an aircraft toilet. But it doesn't. I eat my proverbial words. This is a decent browser and well worth a try, especially if you're currently using an old Netscape 4+ model.

It's not as fast as IE 5.5 and it's not going to topple the king from its throne, but it's good enough to secure a worthwhile slice of the market for Netscape. When combined with the Mozilla/Gecko final release, which should be out in a few months, that market share will be too large for any serious developer to ignore.

Most simple JavaScript works fine in N6. If, for example, you have links created in JavaScript or new windows that open and close, you should be OK. The main problem is if you get into the DOM (Document Object Model). The DOM for N6 isn't the same as for IE4+ or NN4. It's much closer to the W3C recommended DOM1 than either of these, but unfortunately that means the new browser won't accept a lot of DOM-related code already on the Net.

As a general rule, you're entering the realm of the DOM if you mess about with the properties of the Web page or the elements within it. If you don't change a property, you're probably not getting involved with the DOM.

Since the DOMs for IE and N4 were different even before N6 came along, most DOM-related code already recognises the browser (or, as some people say, parses the browser) and supplies separate lines of code for the main types.

If you're not very familiar with JavaScript, this is probably the easiest way to tell if your code will work in N6 unchanged or if it needs updating. Any scripts that devote their first few lines to recognising the browser will almost certainly need to be updated. In most cases they'll need a new section of code added that conforms with DOM1.

Changing the browser recognition element is relatively simple. Here's a detailed guide from WebReference.com and an alternative from Netscape.

The only problem is that after making these simple changes you will need to know what you're doing to rewrite code for DOM1. Note also that most DHTML code written by Dreamweaver and other DHTML authoring applications will need to be adjusted to work in N6.

Other Code

If you're using other proprietary code, this too will fail in N6, including NN4 proprietary code, most notably the use of Layers.

Here is a list of unsupported features:

Proprietary NN4 Features
document.layers[], document.elementName, and other NN4 Layer DOM features
document.tags, document.ids, document.classes, or document.contextual() for setting CSS properties from NN4 JavaScript.
LAYER, ILAYER, and MULTICOL elements
DIV SRC= transclusions (external content imported into an HTML page using <DIV SRC=...)
use of .jar files for SmartUpdate

Proprietary IE4/5 Features
document.all and other IE4/5 DOM features
document.styleSheets[] for setting CSS properties from Internet Explorer JScript
MARQUEE and BGSOUND elements
.cab files

For more details and workarounds see http://sites.netscape.net/ekrockhome/standards.html

Do bear in mind that you will probably need to adjust your DOM-related JavaScript yet again when the final version of Mozilla comes on the market in the first half of next year, at least to make sure the browser gets directed to the same set of code as N6.

One final note, and something that you may wish to point out to colleagues working in pure HTML, is that N6 is not very forgiving of any table with a fixed width that's insufficient to contain its content. Previous browsers forgave this kind of coding error and simply stretched the table to fit, but N6 doesn't like it at all.

Comments and observations on JavaScript coding for N6 are very welcome.



Back to the Web Developer's Journal
Contact WDJ   •    Suits!   •    Propheads!   •    Ponytails!
Discuss   •    Subscribe   •    Search


internet.com

IT | Developer | Internet News | Small Business | Personal Technology | International | Search internet.com | Advertise | Corporate Info
Newsletters | Tech Jobs | E-mail Offers

internet.commerce
Be a Commerce Partner                                
  

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs