Browser Compatibility
with HTML 4.0 (cont.)
from Instant IE4 Dynamic HTML Programmer's
Reference
Having seen in outline how Internet Explorer 4 meets the current W3C proposals
for Project Cougar, let's compare the same feature list with Netscape's new
browser, Communicator 4 (NC4). We won't be attempting to explain the features
in full, because our aim is simply to indicate how close they come to Project
Cougar. However, at the end of this section, we'll look briefly at some of
the other new features of NC4.
Netscape Communicator 4's current incarnation does not follow the working
drafts for HTML 4.0 as closely as Netscape would probably have preferred.
However, in most areas, it does provide much of the functionality that Project
Cougar is attempting to bring to the language.
The first thing to note is that NC4 doesn't attempt to provide access to
all the elements in the page. The element object arrays that were part of
the previous browser object model- such as plugins,
embeds, applets, forms,
elements, etc-are still available through JavaScript,
but there is no universal array of all the element tags. The tags
and ids arrays only provide access to the styles
that have been applied to individual elements. These arrays are not 'true'
document object arrays either, in that they have no length
property and cannot be iterated through like the other element arrays.
The major new system for providing dynamic content is based on two new tags,
<LAYER> and <ILAYER>.
These can be positioned (absolutely in the case of the <LAYER>
tag), moved, hidden, and their content and z-order changed, while the main
document is displayed in the browser. They also provide a parent/child navigation
system through special properties. However, few of the other existing elements
have these kinds of abilities. For example, it isn't possible to absolutely
position headings, images, or other block elements, without placing them within
a <LAYER> element.
NC4 can retrieve the contents of the current user's selection in the document,
as a simple string, using the getSelection method.
It can search for text in the page using the new find
method. There is no system for changing the displayed content outside a layer,
although this is not generally a problem. Layers are flexible enough to allow
a page to be created where the contents can be changed dynamically by code
running in the browser.
The Project Cougar proposals include the requirement for the browser to provide
a rich selection of events for all objects, which can be bound to script code
in order to allow the construction of completely interactive documents.
NC4 implements a new Event object that provides
information about all the scriptable events that are occurring in the browser.
Instead of providing event bubbling as the default, as discussed by W3C, Communicator
implements a system called event capturing. The document
or window can be instructed, with the captureEvents
method, to capture events originally destined for a contained element. The
event can then be handled or routed to the original element with a routeEvent
method call. This system also allows events to be captured in other documents
loaded into a <FRAMESET>, depending on the
security settings in those documents.
Project Cougar specifies a 'rich set of events for all elements', and NC4
doesn't fully deliver at present. New events are available, but the range
of elements to which they apply is very limited. For example, the new mouse
and key-press events provide a lot of opportunity
to make pages more reactive to the viewer. However, they are generally restricted
to elements like the document, links, and in some cases images.
Netscape were early adopters of styles and style sheets, and NC4 is documented
as offering 'full support for the CSS1 standards'. This includes the recommendations
for the new positioning properties and-once defined-the styles can be accessed
using JavaScript to provide dynamic pages.
Netscape have also developed a separate style language called JavaScript
Style Sheets (JSS), which uses the hyphen-less syntax for the style property
names. This works in a similar way to the CSS methods we've seen in this book,
but uses JavaScript methods to assign the styles to elements. It provides
absolute positioning and access to the style properties of elements.
NC4 now contains a JavaScript delete method that can remove objects, properties
or elements from the page. Finally, NC4 provides support for the two tags
<SPAN> and <DIV>, in a way that is documented to be compatible
with the current proposals. Remember, however, that the <DIV> tag in
NC4 does not provide any events, and so is not compatible with IE4 dynamic
pages that uses events generated from a <DIV> tag.
The Project Cougar proposals require the browser to expose information about
the document, its embedded objects, the user agent (browser) itself and any
cookies available for the current document. This is done using the window
and document objects, plus their subsidiary objects (such as navigator),
and the various arrays of contained objects (such as images,
links, forms, etc.)
Project Cougar also requires a document-wide error reporting and logging
system to be in place. Through JavaScript, NC4 provides an onerror
event for images and the script in the page. There is no indication of how
it will support other document-based errors at present.
The Project Cougar Scripting proposals include the requirement for support
of the SRC and TYPE
attributes in a <SCRIPT> tag, allowing a
script to be downloaded separately from the initial document.
NC4 implements an interpreter for JavaScript, and the <SCRIPT>
tag supports the SRC attribute in order to allow
signed (secure) scripts to be imported into a page. Although, this is not
completely in line with current Project Cougar proposals, although it is closer
than Internet Explorer 4 at present.
Changes are also proposed in the HTML 4.0 working drafts to replace the LANGUAGE
attribute with TYPE, i.e. TYPE="script/javascript".
This is not supported at present.
Project Cougar, and the HTML 4.0 working draft, talk about providing better
access to elements on a form. This is with new attributes such as DISABLED,
READONLY, ACCESSKEY
and TABINDEX. There are also new tags proposed-<BUTTON>,
<FIELDSET>, <LEGEND>
and <LABEL>.
There are even indications of future direction in the provision of more intrinsic
controls such as scroll bars, tabular entry fields and multiple page layouts.
In Communicator version 4.0, there is no support for these enhanced HTML
forms. As enhanced forms were originally a Microsoft proposal, it's perhaps
not surprising that this feature is yet to be implemented in NC4. It's likely
that there will be some considerable changes to the working drafts in this
area before final ratification.
Communicator does not support the <OBJECT>
tag at present, despite rumors circulating during its development. In general,
executable objects are inserted using an <APPLET>
tag, and embedded documents and other files with an <EMBED>
tag. The proposals for HTML 4.0 suggest that both these tags will disappear,
to be replaced with <OBJECT>. In fact, even
the <IMG> tag is destined to be replaced
by extensions to the <OBJECT> tag, as mentioned
earlier.
New Features in Netscape Communicator
The new document-oriented features in NC4 do provide the web page
author with some interesting new possibilities, although not fully in line
with the current scope of Project Cougar. One of the biggest changes is a
new system of creating layers in a page, and placing elements and scripts
into each layer. The layers can even be separate pages, loaded from the server.
They are created with the new <LAYER> and <ILAYER> tags, which
also provide positioning and z-order control and respond to a limited range
of events.
The <LAYER> tag behaves like an element with a position style of absolute,
while <ILAYER> (short for in-line layer) behaves like an element with
a position style setting of relative. By moving and resizing the layers, in
a way similar to the method we demonstrated with a <DIV> document division
in earlier chapters, a dynamic page can be created.
In NC4, you can now take advantage of a 'proper' in-built timer, that doesn't
need to be reset after each timeOut event. The new setInterval and clearInterval
methods of the window object start and stop a repeating internal timer.
NC4 also adds methods to print the contents of the page, and -- like IE4
-- now includes an object that provides information about the user's display
capabilities, the screen object. Finally NC4 offers a feature known as Dynamic
Fonts, which allows the web page author to take advantage of different fonts
in any document, by explicitly providing a link to the 'new' fonts it uses.
This allows the author to get away from the Courier, Arial and Times Roman
fonts that give all current HTML pages a 'samey' feel.
For a full list of the new features in Netscape Communicator
4, visit their web site at developer.netscape.com/library.
Click to purchase
Wrox Press Ltd.
July 1997
Sections:
1-Introduction
2-Project Cougar
3-Browser Compatibility w/Cougar
4-Backward Compatibility Issues
5-Creating Compatible Sites
6-Summary
7-Authors' Bios
Reprinted with permission and adapted for IDM by Gordon Benett.
Copyright © 1997 by Wrox Press Ltd.