Click to return to the DHTML, HTML     
Web Workshop  |  DHTML, HTML & CSS

Microsoft Dynamic HTML Reviewer's Guide

Microsoft Corporation

October 17, 1997

Note The information contained in this document represents the current view of Microsoft Corp. on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT.

Review Considerations

This guide outlines features of Dynamic HTML, a technology delivered in the final release of Microsoft® Internet Explorer 4.0. In this Reviewer's Guide, it is assumed that the reviewer understands the core principles behind object-oriented technology, including objects, properties, methods, and events. Dynamic HTML is based on several World Wide Web Consortium (W3C) working drafts and recommendations, as outlined further in this guide. See http://www.w3.org/ Non-MS link for more information about these specifications. For more information on Dynamic HTML, please see the DHTML, HTML & CSS section of Web Workshop.

Understanding Interactivity

It is important to define interactivity for the purposes of this guide. The following criteria are suggested for defining a truly interactive Web page:

Reviewer's Guide Demos

This Reviewer's Guide provides code samples to illustrate how "authors," that is, designers and developers, can use Dynamic HTML. To run these code samples properly, you must have Microsoft Internet Explorer 4.0 or later Non-MSDN Online link installed on your machine.

Dynamic HTML Summary

A feature of Microsoft Internet Explorer 4.0, Dynamic HTML is an innovative technology that enables new classes of interactive Web pages. With Dynamic HTML, Web applications can take on consumer appeal rivaling that of CD-ROM titles, and developers can create intranet applications with functional front-end interfaces for data entry or reporting.

Dynamic HTML is an open, language-independent object model for standard HTML. It enables scripts or programs to change the style, content, and structure of a Web page, even after the page has loaded, without requesting a new page from the server. Dynamic HTML features include the following:

Microsoft developed Dynamic HTML technology with three design goals in mind:

Unparalleled Interactivity for the Web

HTML provides authors with rich layout capabilities for text. However, its static nature impedes authors from creating Web pages that are as interactive or appealing as CD-ROM titles or as functional as traditional business applications.

As a result, authors often use scripts for validating forms and basic animation, and components for client-side functionality. These scripts and components can access only a small subset of page elements and customize these elements only at load time, not in response to user actions. Once a page has loaded, page elements become static.

Changing a page's structure, content, or style after the page has loaded requires requesting a new page from the server. This slows the Web experience for end users and also requires authors to write multiple pages.

Dynamic HTML was designed to address this problem. It enables authors update page elements any time, even after a page loads, without requesting a new page from the server.

Author benefits

User benefits

Easy Authoring

Making Web pages dynamic used to require objects such as Java applets or ActiveX™ controls. Although these components perform useful tasks, they can be difficult to develop, especially when compared to writing HTML and script.

Dynamic HTML makes interactivity accessible to HTML authors, developers, and designers.

Author benefits

Open Standards-Based

Authors have typically faced a difficult choice with proprietary HTML extensions. They've had to either forgo these extensions or develop multiple sets of pages to support competitive browsers.

Dynamic HTML is standards-based to promote interoperability among third-party products and to provide the industry with visibility for leading-edge technology.

Benefits

HTML 4.0 Non-MS link Working Draft

CSS1 Recommendation Non-MS link

CSS Positioning Working Draft Non-MS link

Document Object Model Non-MS link

Dynamic HTML Object and Event Model

Before Dynamic HTML, scripts or components could only access and customize a small number of page elements at Web page load time. Through the Document Object Model, Dynamic HTML exposes all page elements and attributes, providing authors total creative control, even after a Web page has loaded.

Document Object Model

The Document Object Model is the foundation for Dynamic HTML. This object model is consistent with the W3C's direction; it provides many of the features listed in the Document Object Model Preliminary Requirements Non-MS link. The Document Object Model is a significant innovation. It makes all page elements programmable objects, individually and as part of various collections.

The all collection of the document retrieves a collection of element objects that represents all the elements in the HTML document. By providing an index value in this collection, authors can access and manipulate specific page elements.

In addition to the all collection on the document object, each individual element also exposes an all collection. An element's all collection contains all the elements contained by that element, except for the element itself. Each element also exposes a children collection. The children collection contains only the elements that are direct descendants of the element in the HTML hierarchy.

A variety of other collections are supported in Microsoft's implementation of the Document Object Model, including anchors, children, forms, frames, scripts, styleSheets, and more.

Event Model

Dynamic HTML provides events on every element in the document, without new HTML tags or a changed programming paradigm. Every element, at a minimum, exposes these events:

Authors can write scripts that take advantage of these events to interact with users. If the Web page has already loaded, the client need not request a new page from the server to respond to user actions.

Event Bubbling

Dynamic HTML supports event bubbling, a powerful new way to handle events in HTML. First, an event handler is called for the element that is the source of the event. Regardless of whether the event was handled, the event handler for the parent element is called automatically, until the event is bubbled up to the window object or an event handler cancels the bubbling.

Event handlers that otherwise would have to be written for each page element can now be handled by a parent element or the document. By canceling an event bubble, the author can ensure that the event never bubbles past the source element of the event. Please refer to object and event model specifications in the DHTML, HTML, & CSS section of the Workshop for more information.

Benefits

Examples

A table of contents is often provided within a frame in a frameset. In this example, all content is specified using a style sheet, and the display attribute of each <DIV> (group of second-level headings) element is set to display or hide content. New menu choices can be added easily within each <DIV>; no code needs to be changed to add a new menu choice or modify the order of menu choices within each <DIV>.

This table of contents works well in Netscape Navigator 3.0 and 4.0 and Microsoft Internet Explorer version 3.0. In these browsers, a standard set of anchors is displayed.

Dynamic Styles

In the past, changing an element's style meant refreshing the page. With Dynamic HTML, any style attribute for any page element can be updated at any time. The Document Object Model of Dynamic HTML makes all CSS attributes programmable. By updating these attributes with some simple script, authors can change text color, size, spacing, and more.

Dynamic HTML also supports the application of visual filter and transition effects to HTML through CSS syntax (that is, the filter attribute). These filters can be applied to text, images, and any windowless object. A transition is a type of filter that enables a transition from one visual state to another based on a specified duration.

Through CSS, authors can separate page content from presentation, so a single style sheet can define the layout for an entire Web site. Changing the layout can be done through a single file without modifying every document.

Benefits

Style Options

Dynamic HTML enables authors to take advantage of CSS and Microsoft's object model in the following ways:

Examples

Positioning

Historically, positioning elements required building and resizing complex tables. Authors couldn't control an element's position precisely, and users often had a less than compelling Web experience. Changing the position of an element meant refreshing the page with a new table.

Dynamic HTML supports the CSS Positioning working draft, making positioning easier and more precise. Positioning through CSS enables authors to position HTML elements using top, left, and
z-order attributes. By assigning objects different z-orders, authors can cause the objects to overlap, and they can specify which element should be on top of which.

Two types of positioning are supported through CSS Positioning:

Benefits

Please see http://www.w3.org/pub/WWW/TR/PR-CSS1 Non-MS link to view the W3C CSS Recommendation and http://www.w3.org/pub/WWW/TR/WD-positioning.html Non-MS link to view the W3C Working Draft on Positioning HTML Elements with Cascading Style Sheets.

Example

Dynamic Content

To give the illusion of interactivity, authors have traditionally been required to build, and users to download, multiple Web pages. With Dynamic HTML and through the document object model, authors can now add, delete, and replace any page element at any time.

With the Microsoft Dynamic HTML object model, changes to one page element naturally affect other page elements. For instance, text surrounding a resized graphic rewraps around the graphic automatically. In addition, authors can create pages in which users can interact freely with any element. For example, users can decide what color or size a picture should be, with no limits on choice.

Benefits

Accessing and Changing Content

Dynamic HTML provides two techniques for updating page content:

With innerHTML and outerHTML, if the string contains HTML tags, the string is parsed and formatted as it is placed in the document. With innerText and outerText, the given string will be displayed in the Web page, HTML tags and all.
Using the start and end properties and range movement methods on textRange, authors can define the specific range of text to manipulate. Through the pasteHTML method, authors can insert an HTML string into the document.

Examples

Data Binding

Data-driven business applications are increasingly taking advantage of the Web, accessing existing data stored in server databases. These applications often require authors to construct many Web pages that users must navigate through to view and manipulate the data. This can frustrate end users, and also increase server loads.

Dynamic HTML provides data binding features that authors can use to integrate data with native HTML elements on the client. In addition, authors can create applications that present, manipulate (that is, sort or filter), and update data on the client without numerous server round-trips.

Dynamic HTML uses standard tags to define a template that is populated with data on the client and data source objects to supply data to the page. No specific data protocol or DBMS is required to use these data binding features.

Benefits

Obtaining Data

Data source objects supply the data to the Web page. These objects can either be Java applets or ActiveX controls. The data source objects described below are installed with the standard installation of Internet Explorer 4.0.

Authors can construct data source objects to be used with data binding by implementing the OLE-DB Simple Provider (OSP) interface. OSP is a simple, easily implemented interface specification, or API, for exposing data to HTML pages. A set of classes and interfaces are supplied for writing JavaBeans-compliant applets using OSP, as well as type libraries for authoring the interfaces using the Component Object Model (COM).

Thus, data source objects that implement the OSP API can be constructed using Java, Visual Basic, or the Visual C++® development system. Java applets that implement that OSP interface are available, including source code, in the data source object gallery located at http://msdn.microsoft.com/downloads/samples/default.asp . In addition, the source code for the Tabular Data Control, a COM implementation of OSP, is available in the Internet Client SDK.

Presenting Data

Data supplied by a data source object can be bound to HTML elements within the page. The bindings are specified using four new attributes that Microsoft proposed to the W3C: DATASRC, DATAFLD, DATAFORMATAS, and DATAPAGESIZE.

By specifying the DATASRC and DATAFLD attributes on a single-valued data consuming element of a Web page, the Web author fully specifies the binding of an element to data. By specifying DATAFORMATAS on a single-valued element, the Web author indicates how the data should be interpreted. DATAPAGESIZE enables the author to restrict the number of records that are displayed by an element that consumes tabular data. All these properties can be set at run time through the Document Object Model.

These attributes can be used on the following HTML elements: <A>, <APPLET>, <BUTTON>, <DIV>, <FRAME>, <IFRAME>, <IMG>, <INPUT>, <LABEL>, <MARQUEE>, <OBJECT>, <SELECT>, <SPAN> and <TEXTAREA>.

With data binding, authors can present data as follows:

Examples

Scriptlets

Scriptlets are simply Web pages that have been authored using HTML and script. On the 32-bit Windows platform, a scriptlet is a component that takes advantage of COM to define its methods and properties.

Before scriptlets, reusing HTML and script often meant cutting, pasting, and then customizing existing code. With scriptlets, content providers can author their content once, using the HTML and script they know today. They can then let others quickly reuse this scriptlet within other Web pages and applications by following simple conventions to expose well-defined interfaces. Through these interfaces, other authors can customize and reuse existing scriptlet content without having to understand implementation details.

Incorporating scriptlets into Web pages can also reduce performance delays. Given that scriptlets consist only of HTML and script, they are extremely lightweight and quick to download and run for end users. Once the scriptlet is downloaded to the client, it is cached for future use.

Benefits

Defining the Scriptlet Interface

Define a scriptlet interface (specifically its methods and properties) by either of these mechanisms:

With the release of Internet Explorer 5 Beta, Microsoft now recommends DHTML behaviors -- instead of the DHTML scriptlets supported in Internet Explorer 4.0 -- for adding componentized functionality to Web pages. DHTML behaviors provide similar functionality, but with greater speed, power and flexibility. Please note that DHTML behaviors are not supported in Internet Explorer 4.0 or earlier versions.



Back to topBack to top

Did you find this material useful? Gripes? Compliments? Suggestions for other articles? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.