Chapter 11 Dom Html

This chapter extends the DOM Level 2 Core API to describe objects and methods specific to HTML documents. In general, the functionality needed to manipulate hierarchical document structures, elements, and attributes will be found in the core section; functionality that depends on the specific elements defined in HTML will be found in this chapter.

The goals of the HTML-specific DOM API are

• To specialize and add functionality that relates specifically to HTML documents and elements.

• To address issues of backward compatibility with the DOM Level 0.

• To provide convenience mechanisms, where appropriate, for common and frequent operations on HTML documents.

The key differences between the core DOM and the HTML application of DOM is that the HTML Document Object Model exposes a number of convenience methods and properties that are consistent with the existing DOM Level 1 and 0 models and are more appropriate to script writers. In many cases, these enhancements aren’t applicable to a general DOM because they rely on the presence of a predefined DTD. The transitional and frameset DTDs for HTML 4.0 are assumed. Interoperability between implementations is only guaranteed for elements and attributes that are specified in the HTML 4.0 DTDs.

More specifically, this document includes the following specializations for HTML:

• An HTMLDocument interface, derived from the core Document interface. HTMLDocument specifies the operations and queries that can be made on a HTML document.

• An HTMLElement interface, derived from the core Element interface. HTMLElement specifies the operations and queries that can be made on any HTML element. Methods on HTMLElement include those that allow for the retrieval and modification of attributes that apply to all HTML elements.

• Specializations for all HTML elements that have attributes that extend beyond those specified in the HTMLElement interface. For all such attributes, the derived interface for the element contains explicit methods for setting and getting the values.

• The DOM Level 2 includes mechanisms to access and modify style specified through CSS and defines an event model that can be used with HTML documents.

HTMLAnchorElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

The HTMLAnchorElement object represents an HTML anchor element. The HTMLAnchorElement inherits all methods and properties from the HTMLElement object. Table 11.1 contains a list of properties and methods for this object.

Table 11.1 Contents of the HTMLAnchorElement Object

Image

Example

Listing 11.1 illustrates the creation of an HTMLBodyElement using the HTMLDocument object element and then setting its Alink property.

Listing 11.1 Creating an HTMLAnchorElement


<html>
<script language="JavaScript" type="text/javascript">
<!--
var anchorObj = bodyObj.createElement("a");

// -->
</script>
</html>

HTMLAnchorElement.accessKey

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAnchorObj.accessKey

Description

The accessKey property of the HTMLAnchorElement object is a single character access key to give access to the form control.

Example

Listing 11.2 illustrates the creation of an HTMLAnchorElement using the HTMLDocument object element and then setting its accessKey property.

Listing 11.2 Creating an HTMLAnchorElement and Setting Its accessKey Property


<html>
<script language="JavaScript" type="text/javascript">
<!--

var anchorObj = bodyObj.createElement("a");
anchorObj.accessKey = "A";
// -->
</script>
</html>

HTMLAnchorElement.blur()

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAnchorObj.blur()

Description

The blur() method of the HTMLAnchorElement object removes keyboard focus from this element.

Example

Listing 11.3 illustrates the creation of an HTMLAnchorElement using the HTMLDocument object element and then calling its blur() method.

Listing 11.3 Creating an HTMLBodyElement invoking its blur() method


<html>
<script language="JavaScript" type="text/javascript">
<!--
var anchorObj = bodyObj.createElement("a");
anchorObj.blur();
// -->
</script>
</html>

HTMLAnchorElement.charset

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAnchorObj.charset

Description

The charset property of the HTMLAnchorElement object represents the character encoding of the linked resource.

Example

Listing 11.4 illustrates the creation of an HTMLAnchorElement object using the HTMLBodyElement object and then setting its charset property.

Listing 11.4 Creating an HTMLAnchorElement Object and Setting Its charset Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var anchorObj = bodyObj.createElement("a");
anchorObj.charSet = "us/english";
// -->
</script>
</html>

HTMLAnchorElement.coords

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAnchorObj.coords

Description

The coords property of the HTMLAnchorElement object is a comma-separated list of lengths, defining an active region’s geometry. See also shape for the shape of the region.

Example

Listing 11.5 illustrates the creation of an HTMLAnchorElement object using the HTMLBodyElement object and then setting its coords property.

Listing 11.5 Creating an HTMLAnchorElement and Setting Its coords Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var anchorObj = bodyObj.createElement("a");
anchorObj.coords = "12,34,10, 10";
// -->
</script>
</html>

HTMLAnchorElement.focus()

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAnchorObj.focus()

Description

The focus() method of the HTMLAnchorElement object gives keyboard focus to this element.

Example

Listing 11.6 illustrates the creation of an HTMLAnchorElement using the HTMLBodyElement object and the invocation of its focus() method.

Listing 11.6 Creating an HTMLAnchorElement and Invoking Its focus() Method


<html>
<script language="JavaScript" type="text/javascript">
<!--
var anchorObj = bodyObj.createElement("a");
anchorObj.focus();
// -->
</script>
</html>

HTMLAnchorElement.href

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAnchorObj.href

Description

The href property of the HTMLAnchorElement object represents the URI of the linked resource.

Example

Listing 11.7 illustrates the creation of an HTMLAnchorElement using the HTMLBodyElement object and then setting its href property.

Listing 11.7 Creating an HTMLAnchorElement and Setting Its href Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var anchorObj = bodyObj.createElement("a");
anchorObj.href = "http://foo.bar/";
// -->
</script>
</html>

HTMLAnchorElement.hrefLang

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAnchorObj.hrefLang

Description

The hrefLang property of the HTMLAnchorElement object represents the language code of the linked resource.

Example

Listing 11.8 illustrates the creation of an HTMLAnchorElement using the HTMLBodyElement object element and then setting its hrefLang property.

Listing 11.8 Creating an HTMLAnchorElement, and then Setting Its hrefLang Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var anchorObj = bodyObj.createElement("a");
anchorObj.hrefLang = "us/english";
// -->
</script>
</html>

HTMLAnchorElement.name

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAnchorObj.name

Description

The name property of the HTMLAnchorElement object represents the anchor name.

Example

Listing 11.9 illustrates the creation of an HTMLAnchorElement using the HTMLBodyElement object and then setting its name property.

Listing 11.9 Creating an HTMLAnchorElement and Setting Its name Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var anchorObj = bodyObj.createElement("a");
anchorObj.name = "Link to foo site";
// -->
</script>
</html>

HTMLAnchorElement.rel

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAnchorObj.rel

Description

The rel property of the HTMLAnchorElement object represents a forward link type.

Example

Listing 11.10 illustrates the creation of an HTMLAnchorElement using the HTMLBodyElement object element and then setting its rel property.

Listing 11.10 Creating an HTMLAnchorElement and Setting Its name Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var anchorObj = bodyObj.createElement("a");
anchorObj.rel = "http://foo.bar/link.htm";
// -->
</script>
</html>

HTMLAnchorElement.rev

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAnchorObj.rev

Description

The rev property of the HTMLAnchorElement object represents a reverse link type.

Example

Listing 11.11 illustrates the creation of an HTMLAnchorElement using the HTMLBodyElement object and then setting its rev property.

Listing 11.11 Creating an HTMLAnchorElement and Setting Its rev Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var anchorObj = bodyObj.createElement("a");
anchorObj.rev = "http://foo.bar/link.htm";
// -->
</script>
</html>

HTMLAnchorElement.shape

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAnchorObj.shape

Description

The shape property of the HTMLAnchorElement object represents the shape of the active area. The coordinates are given by coords.

Example

Listing 11.12 illustrates the creation of an HTMLAnchorElement using the HTMLBody object and then setting its shape property.

Listing 11.12 Creating an HTMLAnchorElement and Setting its shape Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var anchorObj = bodyObj.createElement("a");
anchorObj.shape = "oval";
// -->
</script>
</html>

HTMLAnchorElement.tabIndex

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAnchorObj.tabIndex

Description

The tabIndex property of the HTMLAnchorElement object represents the index that represents the element’s position in the tabbing order.

Example

Listing 11.13 illustrates the creation of an HTMLAnchorElement using the HTMLBodyElement object and then setting its tabIndex property.

Listing 11.13 Creating an HTMLAnchorElement and Setting Its tabIndex Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var anchorObj = bodyObj.createElement("a");
anchorObj.tabIndex = 3;
// -->
</script>
</html>

HTMLAnchorElement.target

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAnchorObj.target

Description

The target property of the HTMLAnchorElement object represents the frame to render the resource in.

Example

Listing 11.14 illustrates the creation of an HTMLAnchorElement using the HTMLBodyElement object and then setting its target property.

Listing 11.14 Creating an HTMLAnchorElement and Setting Its target Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var anchorObj = bodyObj.createElement("a");
anchorObj.target = "frame1";
// -->
</script>
</html>

HTMLAnchorElement.type

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAnchorObj.type

Description

The type property of the HTMLAnchorElement object represents an advisory content type.

Example

Listing 11.15 illustrates the creation of an HTMLAnchorElement using the HTMLBodyElement object and then setting its type property.

Listing 11.15 Creating an HTMLAnchorElement and Setting Its type Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var anchorObj = bodyObj.createElement("a");
anchorObj.type = "text/html";
// -->
</script>
</html>

HTMLAppletElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

Core DOM HTML object.

Description

This object represents an HTML applet element. The HTMLAppletElement inherits all properties and methods of the HTMLElement object. Table 11.2 contains a list of properties and methods for this object.

Table 11.2 Contents of the HTMLAppletElement Object

Image

Example

Listing 11.16 illustrates the creation of an HTMLAppletElement using the HTMLBodyElement object and then setting its align property.

Listing 11.16 Creating an HTMLAppletElement


<html>
<script language="JavaScript" type="text/javascript">
<!--
var appletObj = bodyObj.createElement("applet");
// -->
</script>
</html>

HTMLAppletElement.align

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAppletObj.align

Description

The align property of the HTMLAppletElement object aligns this object (vertically or horizontally) with respect to its surrounding text.

Example

Listing 11.17 illustrates the creation of an HTMLAppletElement using the HTMLBodyElement object and then setting its align property.

Listing 11.17 Creating an HTMLAppletElement and Setting Its align Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var appletObj = bodyObj.createElement("applet");
appletObj.align = "bottom";
// -->
</script>
</html>

HTMLAppletElement.alt

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAppletObj.alt

Description

The alt property of the HTMLAppletElement object represents the alternate text for user agents not rendering the normal content of this element.

Example

Listing 11.18 illustrates the creation of an HTMLAppletElement using the HTMLBodyElement object and then setting its alt property.

Listing 11.18 Creating an HTMLAppletElement and Setting Its alt Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var appletObj = bodyObj.createElement("applet");
appletObj.alt = "Cannot display applet!";
// -->
</script>
</html>

HTMLAppletElement.archive

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAppletObj.archive

Description

The archive property of the HTMLAppletElement object is a comma-separated archive list.

Example

Listing 11.19 illustrates the creation of an HTMLAppletElement using the HTMLBodyObject object and then setting its archive property.

Listing 11.19 Creating an HTMLAppletElement Object and Setting its archive Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var appletObj = bodyObj.createElement("applet");
appletObj.archive = "foo.jar,bar.jar";
// -->
</script>
</html>

HTMLAppletElement.code

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAppletObj.code

Description

The code property of the HTMLAppletElement object is the applet class file.

Example

Listing 11.20 illustrates the creation of an HTMLAppletElement using the HTMLBodyElement object element and then setting its code property.

Listing 11.20 Creating an HTMLAppletElement and Setting Its code Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var appletObj = bodyObj.createElement("applet");
appletObj.code = "foo.bar.applets.FooApplet";
// -->
</script>
</html>

HTMLAppletElement.codeBase

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAppletObj.codeBase

Description

The codeBase property of the HTMLAppletElement object is an optional base URI for applet.

Example

Listing 11.21 illustrates the creation of an HTMLAppletElement using the HTMLBodyElement object and then setting its codeBase property.

Listing 11.21 Creating an HTMLAppletElement Object and Setting Its code-base Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var appletObj = bodyObj.createElement("applet");
appletObj.codebase = "http://foo.bar/applets/";
// -->
</script>
</html>

HTMLAppletElement.height

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAppletObj.height

Description

The height property of the HTMLAppletElement object allows you to override height.

Example

Listing 11.22 illustrates the creation of an HTMLAppletElement using the HTMLBodyElement object and then setting its height property.

Listing 11.22 Creating an HTMLAppletElement and Setting Its height Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var appletObj = bodyObj.createElement("applet");
appletObj.height = "25";
// -->
</script>
</html>

HTMLAppletElement.hspace

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAppletObj.hspace

Description

The hspace property of the HTMLAppletElement object represents the horizontal space to the left and right of this applet.

Example

Listing 11.23 illustrates the creation of an HTMLAppletElement using the HTMLBodyElement object and then setting its hspace property.

Listing 11.23 Creating an HTMLAppletElement and Setting Its hspace Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var appletObj = bodyObj.createElement("applet");
appletObj.hspace = 2;
// -->
</script>
</html>

HTMLAppletElement.name

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAppletObj.name

Description

The name property of the HTMLAppletElement object contains the name of the applet.

Example

Listing 11.24 illustrates the creation of an HTMLAppletElement using the HTMLBodyElement object and then setting its name property.

Listing 11.24 Creating an HTMLAppletElement and Setting Its name Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var appletObj = bodyObj.createElement("applet");
appletObj.name = "color selector applet";
// -->
</script>
</html>

HTMLAppletElement.object

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAppletObj.object

Description

The object property of the HTMLAppletElement object represents the serialized applet file.

Example

Listing 11.25 illustrates the creation of an HTMLAppletElement using the HTMLBodyElement object and then setting its object property.

Listing 11.25 Creating an HTMLAppletElement and Setting Its object Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var appletObj = bodyObj.createElement("applet");
appletObj.object = "http://foo.bar/applets/colorapplet.ser"
// -->
</script>
</html>

HTMLAppletElement.vspace

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAppletObj.vspace

Description

The vspace property of the HTMLAppletElement object represents the vertical space above and below the applet.

Example

Listing 11.26 illustrates the creation of an HTMLAppletElement using the HTMLBodyElement object and then setting its vspace property.

Listing 11.26 Creating an HTMLAppletElement and Setting Its vspace Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var appletObj = bodyObj.createElement("applet");
appletObj.vspace = 5;
// -->
</script>
</html>

HTMLAppletElement.width

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAppletObj.width

Description

The width property of the HTMLAppletElement object allows you to override width.

Example

Listing 11.27 illustrates the creation of an HTMLAppletElement using the HTMLBodyElement object and then setting its width property.

Listing 11.27 Creating an HTMLAppletElement and Setting Its width Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var appletObj = bodyObj.createElement("applet");
appletObj.width = 30;
// -->
</script>
</html>

HTMLAreaElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents an HTML area element. Table 11.3 contains a list of properties and methods for this object.

Table 11.3 Contents of HTMLAreaElement Object

Image

Example

Listing 11.28 illustrates the creation of an HTMLAreaElement using the HTMLMapElement object and then setting its accessKey property.

Listing 11.28 Creating an HTMLAreaElement Object


<html>
<script language="JavaScript" type="text/javascript">
<!--
var mapObj = bodyObj.createElement("map");
var areaObj = mapObj.createElement("area");
// -->
</script>
</html>

HTMLAreaElement.accessKey

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAreaObj.accessKey

Description

The accessKey property of the HTMLAreaElement object is a single character access key to give access to the form control.

Example

Listing 11.29 illustrates the creation of an HTMLAreaElement using the HTMLMapElement object and then setting its accessKey property.

Listing 11.29 Creating an HTMLAreaElement and Setting Its accessKey Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var mapObj = bodyObj.createElement("map");
var areaObj = mapObj.createElement("area");
areaObj.AccessKey = "Z";// -->
</script>
</html>

HTMLAreaElement.alt

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAreaObj.alt

Description

The alt property of the HTMLAreaElement object represents the alternate text for user agents not rendering the normal content of this element.

Example

Listing 11.30 illustrates the creation of an HTMLAreaElement using the HTMLMapElement object element and then setting its alt property.

Listing 11.30 Creating an HTMLAreaElement and Setting Its alt Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var mapObj = bodyObj.createElement("map");
var areaObj = mapObj.createElement("area");
areaObj.alt = "here is area 1";

// -->
</script>
</html>

HTMLAreaElement.coords

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAreaObj.coords

Description

The coords property of the HTMLAreaElement object is a comma-separated list of lengths, defining an active region’s geometry.

Example

Listing 11.31 illustrates the creation of an HTMLAreaElement using the HTMLMapElement object and then setting its coords property.

Listing 11.31 Creating an HTMLAreaElement and Setting Its coords Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var mapObj = bodyObj.createElement("map");
var areaObj = mapObj.createElement("area");
areaObj.coords = "23,45,34,44";

// -->
</script>
</html>

HTMLAreaElement.href

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAreaObj.href

Description

The href property of the HTMLAreaElement object represents the URI of the linked resource.

Example

Listing 11.32 illustrates the creation of an HTMLAreaElement using the HTMLMapElement object and then setting its href property.

Listing 11.32 Creating an HTMLAreaElement and Setting Its href Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var mapObj = bodyObj.createElement("map");
var areaObj = mapObj.createElement("area");
areaObj.href = "http://foo.bar/link.html";

// -->
</script>
</html>

HTMLAreaElement.noHref

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAreaObj.noHref

Description

The noHref property of the HTMLAreaElement object specifies that this area is inactive; that is, it has no associated action.

Example

Listing 11.33 illustrates the creation of an HTMLAreaElement using the HTMLMapElement object and then setting its noHref property.

Listing 11.33 Creating an HTMLAreaElement and Setting Its noHref Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var mapObj = bodyObj.createElement("map");
var areaObj = mapObj.createElement("area");
areaObj.noHref = true;
// -->
</script>
</html>

HTMLAreaElement.shape

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAreaObj.shape

Description

The shape property of the HTMLAreaElement object represents the shape of the active area. The coordinates are given by coordinates.

Example

Listing 11.34 illustrates the creation of an HTMLAreaElement using the HTMLMapElement object and then setting its shape property.

Listing 11.34 Creating an HTMLAreaElement and Setting Its shape Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var mapObj = bodyObj.createElement("map");
var areaObj = mapObj.cCreateElement("area");
areaObj.shape = "rect";
// -->
</script>
</html>

HTMLAreaElement.tabIndex

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAreaObj.tabIndex

Description

The tabIndex property of the HTMLAreaElement object is a index that represents the element’s position in the tabbing order.

Example

Listing 11.35 illustrates the creation of an HTMLAreaElement using the HTMLMapElement object and then setting its tabIndex property.

Listing 11.35 Creating an HTMLAreaElement and Setting Its tabIndex Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var mapObj = bodyObj.createElement("map");
var areaObj = mapObj.createElement("area");
areaObj.TabIndex = 3;
// -->
</script>
</html>

HTMLAreaElement.target

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlAreaObj.target

Description

The target property of the HTMLAreaElement object represents the frame to render the resource in.

Example

Listing 11.36 illustrates the creation of an HTMLAreaElement using the HTMLMapElement object and then setting its target property.

Listing 11.36 Creating an HTMLAreaElement and Setting Its target Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var mapObj = bodyObj.createElement("map");
var areaObj = mapObj.createElement("area");
areaObj.target = "mainframe";
// -->
</script>
</html>

HTMLBaseElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

The HTMLBaseElement object encapsulates the Document base URI. HTMLBaseElement inherits all methods and properties from HTMLElement. Table 11.4 contains a list of properties and methods for this object.

Table 11.4 Properties of theHTMLBaseElement Object

Image

Example

Listing 11.37 illustrates the creation of an HTMLBaseElement using the HTMLDocument object.

Listing 11.37 Creating an HTMLBaseElement

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var baseElement = htmlDoc.createElement("base");
// -->
</script>
</html>

HTMLBaseElement.href

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlBaseElemObj.href

Description

The href property of the HTMLBaseElement object represents the base URI for this element.

Example

Listing 11.38 illustrates the creation of an HTMLBaseElement using the HTMLDocument object element and then setting its href and target properties.

Listing 11.38 Creating an HTMLBaseElement and Setting Its href Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var baseElement = htmlDoc.createElement("base");
baseElement.href = "http://foo.bar/";
// -->
</script>
</html>

HTMLBaseElement.target

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlBaseElemObj.target

Description

The target property of the HTMLBaseElement object represents the default target frame.

Example

Listing 11.39 illustrates the creation of an HTMlBaseElement using the HTMLDocument object element and then setting its target property.

Listing 11.39 Creating an HTMLBaseElement and Setting Its target Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var baseElement = htmlDoc.createElement("base");
baseElement.target = "MainFrame";
 // -->
</script>
</html>

HTMLBaseFontElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents an HTML BASEFONT element. The HTMLBaseFontElement inherits all methods and properties from the HTMLElement object. Table 11.5 contains a list of properties for this object.

Table 11.5 Properties of theHTMLBaseFontElement object

Image

Example

Listing 11.40 illustrates the creation of an HTMLBaseFontElement using the HTMLBodyElement object.

Listing 11.40 Creating an HTMLBaseFontElement Object

<html>
<script language="JavaScript" type="text/javascript">
<!--
var baseFontObj = bodyObj.createElement("basefont");

// -->
</script>
</html>

HTMLBaseFontElement.color

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlBaseFontObj.color

Description

The color property of the HTMLBaseFontElement object represents the color of this font.

Example

Listing 11.41 illustrates the creation of an HTMLBaseFontElement using the HTMLBody object and then setting its color property.

Listing 11.41 Creating an HTMLBaseFontElement and Setting Its color Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var baseFontObj = bodyObj.createElement("basefont");
baseFontObj.color = "#FFFFFF";
// -->
</script>
</html>

HTMLBaseFontElement.face

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlBaseFontObj.face

Description

The face property of the HTMLBaseFontElement object is the font face identifier.

Example

Listing 11.42 illustrates the creation of an HTMLBaseFontElement using the HTMLBodyElement object and then setting its face property.

Listing 11.42 Creating an HTMLBaseFontElement and Setting Its face Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var baseFontObj = bodyObj.createElement("basefont");
baseFontObj.face = "courier";
// -->
</script>
</html>

HTMLBaseFontElement.size

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlBaseFontObj.size

Description

The size property of the HTMLBaseFontElement object is the font size.

Example

Listing 11.43 illustrates the creation of an HTMLBaseFontElement using the HTMLBodyElement object and then setting its size property.

Listing 11.43 Creating an HTMLBaseFontElement and Setting Its size Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var baseFontObj = bodyObj.createElement("basefont");
baseFontObj.size = 12;
// -->
</script>
</html>

HTMLBodyElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object encapsulates the HTML document body. This element is always present in the DOM API, even if the tags are not present in the source document.HTMLBodyElement inherits all methods and properties from HTMLElement. Table 11.6 contains a list of properties for this object.

Table 11.6 Properties of theHTMLBodyElement Object

Image

Example

Listing 11.44 illustrates the creation of an HTMLBodyElement.

Listing 11.44 Creating an HTMLBodyElement Object

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
// -->
</script>
</html>

HTMLBodyElement.aLink

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlBodyObj.aLink

Description

The aLink property of the HTMLBodyElement object represents the color of active links (after mouse button down, but before mouse button up).

Example

Listing 11.45 illustrates the creation of an HTMLBodyElement using the HTMLDocumentobject element and then setting its aLink property.

Listing 11.45 Creating an HTMLBodyElement and Setting Its aLink Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
bodyObj.aLink = "#FF0000"
  // -->
</script>
</html>

HTMLBodyElement.background

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlBodyObj.background

Description

The background property of the HTMLBodyElement object is the URI of the background texture tile image.

Example

Listing 11.46 illustrates the creation of an HTMLBodyElement using the HTMLDocumentobject and then setting its background property.

Listing 11.46 Creating an HTMLBodyElement and Setting Its background Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
bodyObj.background = "http://foo.bar/images/tile.jpg"
// -->
</script>
</html>

HTMLBodyElement.bgColor

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlBodyObj.bgColor

Description

The bgColor property of the HTMLBodyElement object is the document background color.

Example

Listing 11.47 illustrates the creation of an HTMLBodyElement using the HTMLDocumentobject element and then setting its bgColor property.

Listing 11.47 Creating an HTMLBodyElement and Setting Its bgColor Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
bodyObj.bgColor = "#FFFFFF";
// -->
</script>
</html>

HTMLBodyElement.link

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlBodyObj.link

Description

The link property of the HTMLBodyElement object is the color of links that are inactive and unvisited.

Example

Listing 11.48 illustrates the creation of an HTMLBodyElement using the HTMLDocumentobject element and then setting its link property.

Listing 11.48 Creating an HTMLBodyElement and Setting Its link Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
bodyObj.link = "#000066"
// -->
</script>
</html>

HTMLBodyElement.text

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlBodyObj.text

Description

The text property of the HTMLBodyElement object is the document text color.

Example

Listing 11.49 illustrates the creation of an HTMLBodyElement using the HTMLDocumentobject element and then setting its text property.

Listing 11.49 Creating an HTMLBodyElement and Setting Its text Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
bodyObj.text = "#000000"
// -->
</script>
</html>

HTMLBodyElement.vLink

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlBodyObj.vLink

Description

The vLink property of the HTMLBodyElement object represents the color of links that have been visited by the user.

Example

Listing 11.50 illustrates the creation of an HTMLBodyElement using the HTMLDocumentobject element and then setting its vLink property.

Listing 11.50 Creating an HTMLBodyElement and Setting Its vLink Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
bodyObj.vLink = "#6666CC"
// -->
</script>
</html>

HTMLBRElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents the HTML element that forces a line break. The HTMLBRElementinherits all methods and properties of the HTMLElement object. The property for this object is as follows:

Image

Example

Listing 11.51 illustrates the creation of an HTMLBRElement using the HTMLBodyElement.

Listing 11.51 Creating an HTMLBRElement Object

<html>
<script language="JavaScript" type="text/javascript">
<!--
var brObj = bodyObj.createElement("br");
// -->
</script>
</html>

HTMLBRElement.clear

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlBRObj.clear

Description

The clear property of the HTMLBRElement object controls flow of text around floats.

Example

Listing 11.52 illustrates the creation of an HTMLBRElement using the HTMLBodyElementobject and then setting its clear property.

Listing 11.52 Creating an HTMLBRElement and Setting Its clear Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var brObj = bodyObj.createElement("br");
brObj.clear = "left";
// -->
</script>
</html>

HTMLButtonElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents an HTML button element. It inherits all methods and properties of the HTMLElement object. Table 11.7 contains a list of properties for this object.

Table 11.7 Properties of theHTMLButtonElement Object

Image

Example

Listing 11.53 illustrates the creation of a HTMLButtonElement using a HTMLFormElement and setting its type property.

Listing 11.53 Creating an HTMLButtonElement and Setting Its type Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
var formObj = bodyObj.createElement("form");
var buttonObj = formObj.createElement("button");
buttonObj.type = "submit";
// -->
</script>
</html>

HTMLButtonElement.accessKey

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlButtonObj.accessKey

Description

The accessKey property of the HTMLButtonElement object is a single character access key to give access to the form control.

Example

Listing 11.54 illustrates the creation of an HTMLButtonElement using the HTMLFormElement object and then setting its accessKey property.

Listing 11.54 Creating an HTMLButtonElement and Setting Its accessKey Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var buttonObj = formObj.createElement("button");
buttonObj.accessKey = "B";
// -->
</html>

HTMLButtonElement.disabled

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlButtonObj.disabled

Description

The disable property of the HTMLButtonElement object allows you to disable button instances.

Example

Listing 11.55 illustrates the creation of an HTMLButtonElement using the HTMLFormElement object and then setting its disabled property.

Listing 11.55 Creating an HTMLButtonElement and Setting Its disabled Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var buttonObj = formObj.createElement("button");
buttonObj.disabled = true;
// -->
</script>
</html>

HTMLButtonElement.form

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlButtonObj.form

Description

The form property of the HTMLButtonElement object returns the FORM element containing this control. It returns Null if this control isn’t within the context of a form.

Example

Listing 11.56 illustrates the creation of an HTMLButtonElement using the HTMLFormElement object and then reading its form Property.

Listing 11.56 Creating an HTMLButtonElement and Reading its form Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var buttonObj = formObj.createElement("button");
if(buttonObj.form.name == "emailForm")
    processEmail(buttonObj.form);
// -->
</script>
</html>

HTMLButtonElement.name

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlButtonObj.name

Description

The name property of the HTMLButtonElement object represents a form control or object name when submitted with a form.

Example

Listing 11.57 illustrates the creation of an HTMLButtonElement using the HTMLFormElement object and then setting its name property.

Listing 11.57 Creating an HTMLButtonElement and Setting Its name Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var buttonObj = formObj.createElement("button");
buttonObj.name = "foo";
// -->
</script>
</html>

HTMLButtonElement.tabIndex

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlButtonObj.tabIndex

Description

The tabIndex property of the HTMLButtonElement object is the index that represents the element’s position in the tabbing order.

Example

Listing 11.58 illustrates the creation of an HTMLButtonElement using theHTMLFormElement object and then setting its tabIndex property.

Listing 11.58 Creating an HTMLButtonElement and Setting Its tabIndex Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var buttonObj = formObj.createElement("button");
buttonObj.tabIndex = 10;
// -->
</script>
</html>
<html> <script language="JavaScript" type="text/javascript"> <!--var buttonObj = formObj.createElement("button"); buttonObj.tabIndex = 10; // --> </script> </html>

HTMLButtonElement.type

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlButtonObj.type

Description

The type property of the HTMLButtonElement object represents the type of button.

Example

Listing 11.59 illustrates the creation of an HTMLButtonElement using theHTMLFormElement object element and then setting its type property.

Listing 11.59 Creating an HTMLButtonElement and Setting Its type Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var buttonObj = formObj.createElement("button");
buttonObj.type = "submit";
// -->
</script>
</html>

HTMLButtonElement.value

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlButtonObj.value

Description

The value property of the HTMLButtonElement object is the current form control value.

Example

Listing 11.60 illustrates the creation of an HTMLButtonElement using theHTMLFormElement object element and then setting its value property.

Listing 11.60 Creating an HTMLButtonElement and Setting Its value Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var buttonObj = formObj.createElement("button");
buttonObj.type = "submit";
buttonObj.value = "Submit";
// -->
</script>
</html>

HTMLCollection

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

Core DOM HTML object.

Description

An HTMLCollection is a list of nodes. An individual node can be accessed by either ordinal index or the node’s name or ID attributes.

Table 11.8 contains a list of the property and methods for this object.

Table 11.8 Contents of theHTMLCollection Object

Image

Example

Listing 11.61 illustrates the creation of an HTMLDocument using theHTMLDOMImplementation object then iterating through that document’s images property processing each image.

Listing 11.61 Iterating Through an HTMLCollection

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var htmlDocImages = htmlDoc.images;
var i = 0;
while(i < htmlDocImages.length) {
    var image = htmlDocImages.item(i);
    processImageSrc(imageSrc);
    i++;

}
</script>
</html>

HTMLCollection.item()

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlCollectionObj.item(index)

Description

The item() method of the HTMLCollection object retrieves a node specified by number index. Nodes are numbered in tree order (depth-first traversal order).

Example

Listing 11.63 illustrates the creation of an HTMLDocument using theHTMLDOMImplementation object and then iterating through that document’s imagesproperty processing each image.

Listing 11.63 Iterating Through an HTMLCollection

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var htmlDocImages = htmlDoc.images;
var i = 0;
while(i < htmlDocImages.length) {
    var image = htmlDocImages.item(i);
    processImageSrc(imageSrc);
    i++;
}
</script>
</html>

HTMLCollection.length

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlCollectionObj.length

Description

The length property of the HTMLCollection object specifies the length or size of the list.

Example

Listing 11.62 illustrates the creation of an HTMLDocument using theHTMLDOMImplementation object and then iterating through that document’s imagesproperty processing each image.

Listing 11.62 Iterating Through an HTMLCollection Using the length Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var htmlDocImages = htmlDoc.images;
var i = 0;
while(i < htmlDocImages.length) {
    var image = htmlDocImages.item(i);
    processImageSrc(imageSrc);
    i++;

}
</script>
</html>

HTMLCollection.namedItem()

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlCollectionObj.namedItem(name)

Description

The namedItem() method of the HTMLCollection object retrieves a Node using a name. It first searches for a Node with a matching ID attribute. If it doesn’t find one, it then searches for a Node with a matching name attribute, but only on those elements that are allowed a name attribute.

Example

Listing 11.64 illustrates the creation of an HTMLDocument using theHTMLDOMImplementation object and the iteration through that document’s imagesproperty processing each image.

Listing 11.64 Iterating Through an HTMLCollection Using the namedItem() Method

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var htmlDocImages = htmlDoc.images;
var i = 0;
while(i < htmlDocImages.Length) {
    var image = htmlDocImages.namedItem("iconImage");
    processImageSrc(imageSrc);
    i++;
}
</script>
</html>

HTMLDirectoryElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents an HTML directory element. The HTMLDirectoryElement object inherits all methods and properties from HTMLElement. The property for this object is as follows:

Image

Example

Listing 11.65 illustrates the creation of an HTMLDirectoryElement using theHTMLDListElement.

Listing 11.65 Creating an HTMLDirectory

<html>
<script language="JavaScript" type="text/javascript">
<!--
var dListObj = bodyObj.createElement("dlist");
var directoryObj = dListObj.createElement("directory");

// -->
</script>
</html>
<html> <script language="JavaScript" type="text/javascript"> <!--var dListObj = bodyObj.createElement("dlist"); var directoryObj = dListObj.createElement("directory");
// --> </script> </html>

HTMLDirectoryElement.compact

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDirectoryObj.compact

Description

The compact property of the HTMLDirectoryElement object reduces the spacing between list items.

Example

Listing 11.66 illustrates the creation of an HTMLDirectoryElement using theHTMLDListElement object and then setting its compact property.

Listing 11.66 Creating an HTMLDirectoryElement and Setting Its compact Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var dListObj = bodyObj.createElement("dlist");
var directoryObj = dListObj.createElement("directory");
directoryObj.compact = true;
// -->
</script>
</html>

HTMLDivElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents an HTML generic block container. The HTMLDivElement object inherits all methods and properties from HTMLElement. The property for this object is as follows:

Image

Example

Listing 11.67 illustrates the creation of an HTMLDivElement using theHTMLBodyElement object and then setting its align property.

Listing 11.67 Creating an HTMLDivElement and Setting Its align Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var divObj = bodyObj.createElement("div");
divObj.align = "top";
// -->
</script>
</html>

HTMLDivElement.align

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDivObj.align

Description

The align property of the HTMLDivElement object represents the horizontal text alignment.

Example

Listing 11.68 illustrates the creation of an HTMLDivElement using theHTMLBodyElement object and then setting its align property.

Listing 11.68 Creating an HTMLDivElement and Setting Its align Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var divObj = bodyObj.createElement("div");
divObj.align = "botton";
// -->
</script>
</html>

HTMLDListElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents an HTML directory list element. The HTMLDListElement object inherits all methods and properties from HTMLElement. The property for this object is as follows:

Image

Example

Listing 11.69 illustrates the creation of an HTMLDListElement using theHTMLBodyElement object element and then setting its compact property.

Listing 11.69 Creating an HTMLDListElement and Setting Its compact Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var dListObj = bodyObj.createElement("dlist");
dListObj.compact = true;
// -->
</script>
</html>

HTMLDListElement.compact

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDListObj.compact

Description

The compact property of the HTMLDListElement object reduces the spacing between list items.

Example

Listing 11.70 illustrates the creation of an HTMLDListElement using theHTMLBodyElement object element and then setting its compact property.

Listing 11.70 Creating an HTMLDListElement and Setting Its compact Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var dListObj = bodyObj.createElement("dlist");
dListObj.compact = true;
// -->
</script>
</html>

HTMLDocument

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

An HTMLDocument is the root of the HTML hierarchy and holds the entire content. Besides providing access to the hierarchy, it also provides some convenience methods for accessing certain sets of information from the document. Table 11.9 contains a list of properties and methods for this object.

Table 11.9 Contents of theHTMLDocument Object

Image

Example

Listing 11.71 creates a new HTMLDocument object using the createHTMLDocument()method of HTMLDOMImplementation.

Listing 11.71 Creating a New HTMLDocument

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var textArea = htmlDoc.createElement("textarea");
textArea.value = "Here's some text in a TEXTAREA");
// -->
</script>
</html>

HTMLDocument.anchors

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDoc.anchors

Description

The anchors property of the HTMLDocument object is a collection of all the anchor (A) elements in a document with a value for the name attribute.

 

Example

Listing 11.72 illustrates the creation of an HTMLDocument using the HTMLDOMImplementation object then iterating through that document’s anchors property processing each anchor element.

Listing 11.72 Iterating Through a Document’s anchors

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var htmlDocAnchors = htmlDoc.anchors;
var i = 0;
while(i < htmlDocAnchors.length) {
    var anchor = htmlDocAnchors.item(i);
    processAnchor(anchor);
    i++;
}
// -->
</script>
</html>

HTMLDocument.applets

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDoc.applets

Description

The applets property of the HTMLDocument object is a collection of all the OBJECT elements that include applets and APPLET (deprecated) elements in a document.

Example

Listing 11.73 illustrates the creation of an HTMLDocument using the HTMLDOMImplementation object then iterating through that document’s applets property processing each applet.

Listing 11.73 Iterating Through a Document’s applets

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var htmlDocApplets = htmlDoc.applets;
var i = 0;
while(i < htmlDocApplets.length) {
    var applet = htmlDocImages.item(i);
    processImageSrc(applet);
    i++;
}

// -->
</script>
</html>

HTMLDocument.body

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDoc.body

Description

The body property of the HTMLDocument object is the element that contains the content for the document. In documents with BODY contents, this returns the BODY element. In frameset documents, this returns the outermost FRAMESET element.

Example

Listing 11.74 creates a new HTMLDocument object using the createHTMLDocument() method of HTMLDOMImplementation and then changes the background color of the body property.

Listing 11.74 Inspecting and Modifying the body Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var docBody = htmlDoc.body;
docBody.bgColor = "#FFFFFF";
// -->
</script>
</html>

HTMLDocument.close()

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDoc.close()

Description

The close() method of the HTMLDocument object closes a document stream opened by open() and forces rendering.

Example

Listing 11.75 illustrates the creation of an HTMLDocument using the HTMLDOMImplementation object and then using the open() method to open this document for writing. A cookie is added and then the document is closed using close().

Listing 11.75 Closing an HTMLDocument Using the close() Method

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
htmlDoc.cookie = "sessionId=3213;expires=34283028"
htmlDoc.close();
// -->
</script>
</html>

HTMLDocument.cookie

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDoc.cookie

Description

The cookie property of the HTMLDocument object represents the cookies associated with this document. If there are none, the value is an empty string. Otherwise, the value is a string: a semicolon-delimited list of name=value pairs for all the cookies associated with the page; for example, name=value;expires=date.

Example

Listing 11.76 illustrates the creation of an HTMLDocument using the HTMLDOMImplementation object and then accessing the cookie property and setting its value.

Listing 11.76 Accessing the cookie Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
htmlDoc.cookie = "sessionId=3213;expires=34283028"
}
</html>

HTMLDocument.domain

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDoc.domain

Description

The domain property of the HTMLDocument object represents the domain name of the server that served the document, or Null if the server cannot be identified by a domain name.

Example

Listing 11.77 creates a new HTMLDocument object using the createHTMLDocument() method of HTMLDOMImplementation and then inspects the domain property to see which domain the page originated from.

Listing 11.77 Inspecting the domain Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
if(htmlDoc.domain == "foo.bar")
    cameFromFooBar = true;
// -->
</script>
</html>

HTMLDocument.forms

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDoc.forms

Description

The forms property of the HTMLDocument object is a collection of all the forms of a document.

Example

Listing 11.78 illustrates the creation of an HTMLDocument using theHTMLDOMImplementation object and then iterating through that document’s formsproperty processing the form with the name "emailForm".

Listing 11.78 Iterating Through a Document’s forms

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var htmlDocForms = htmlDoc.forms;
var i = 0;
while(i < htmlDocForms.length) {
    var form = htmlDocforms.Item(i);
    if(form.name == "emailForm")
       processEmailForm(form);
    i++;
}
// -->
</script>
</html>

HTMLDocument.getElementsByName()

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDoc.getElementsByName(name )

Description

The getElementsByName() method of the HTMLDocument object returns the (possibly empty) collection of elements whose name value is given by name.

Example

Listing 11.79 illustrates the creation of an HTMLDocument using the HTMLDOMImplementation object and then iterating through that document’s list of images using the getElementsByName() method processing each image element.

Listing 11.79 Iterating Through a Document’s Images Using the getElementsByName() Method

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var imageList = htmlDoc.getElementsByName("image");
var i = 0; 
while(i < imageList.length) {
    var image = imageList.item(i);
    processImage(image);
    i++;
}
</html>

HTMLDocument.images

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDoc.images

Description

The images property of the HTMLDocument object is a collection of all the IMG elements in a document. The behavior is limited to IMG elements for backward compatibility.

Example

Listing 11.80 illustrates the creation of an HTMLDocument using the HTMLDOMImplementation object and then iterating through that document’s imagesproperty processing each image.

Listing 11.80 Iterating Through an HTMLCollection

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var htmlDocImages = htmlDoc.images;
var i = 0;
while(i < htmlDocImages.length) {
    var image = htmlDocImages.namedItem("iconImage");
    processImageSrc(imageSrc);
    i++;
}
// -->
</script>
</html>

HTMLDocument.links

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDoc.links

Description

The links property of the HTMLDocument object is a collection of all AREA elements and anchor (A) elements in a document with a value for the href attribute.

Example

Listing 11.81 illustrates the creation of an HTMLDocument using theHTMLDOMImplementation object and then iterating through that document’s linksproperty processing each applet.

Listing 11.81 Iterating Through a Document’s links

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var htmlDocLinks = htmlDoc.links;
var i = 0;
while(i < htmlDocApplets.length) {
    var link = htmlDocLinks.item(i);
    processLink(link);
    i++;
}
// -->
</script>
</html>

HTMLDocument.open()

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDoc.open()

Description

The open() method of the HTMLDocument object is used to open a document stream for writing. If a document exists in the target, this method clears it.

Example

Listing 11.82 illustrates the creation of an HTMLDocument using the HTMLDOMImplementation object and then using the open() method to open this document for writing.

Listing 11.82 Opening an HTMLDocument Using the open() Method

<html> <script language="JavaScript" type="text/javascript"><!--var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
htmlDoc.cookie = "sessionId=3213;expires=34283028"
htmlDoc.close();
// -->
</script>
</html>

HTMLDocument.referrer

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDoc.referrer

Description

The referrer property of the HTMLDocument object returns the URI of the page that linked to this page. The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark).

Example

Listing 11.83 creates a new HTMLDocument object using the createHTMLDocument() method of HTMLDOMImplementation and then inspects the referrer property to see which server the page originated from.

Listing 11.83 Inspecting the referrer Property

<html><br/><script language="JavaScript" type="text/javascript"><br/><!--<br/>var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc"); htmlDoc.open(); if(htmlDoc.referrer == "http://www.foo.bar/index.htm")    cameFromFooBar = true; // --> </script> </html>

HTMLDocument.title

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDoc.title

Description

The title property of the HTMLDocument object represents the title of a document as specified by the TITLE element in the head of the document.

Example

Listing 11.84 creates a new HTMLDocument object using the createHTMLDocument() method of HTMLDOMImplementation and then changes the title.

Listing 11.84 Changing the title Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
htmlDoc.title = "New Title for My HTML Doc";
// -->
</script>
</html>

HTMLDocument.URL

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDoc.URL

Description

The URL property of the HTMLDocument object represents the complete URI of the document.

Example

Listing 11.85 creates a new HTMLDocument object using the createHTMLDocument() method of HTMLDOMImplementation and then creates a TEXTAREA element and sets its value to be that of the URL property.

Listing 11.85 Inpsecting the URL Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
 var  htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var  textArea = htmlDoc.createElement("textarea");
textArea.value = htmlDoc.URL;
// -->
</script> </html>

HTMLDocument.write()

JavaScript 1.5+, JScript

5+ Nav6+, IE5+

 

Syntax

htmlDoc.write(string)

Description

The write() method of the HTMLDocument object is used to write a string to a document stream opened by open(). The string is parsed into the document’s structure model.

Example

Listing 11.86 illustrates the creation of an HTMLDocument using theHTMLDOMImplementation object and then using the write() method to write text data to this document.

Listing 11.86 Using the write() Method

<html>
<script language="JavaScript"  type="text/javascript">
<!--
var  htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
htmlDoc.write("<h1>Hello World</h1>");
htmlDoc.close();

// --> </html>

HTMLDocument.writeln()

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDoc.writeln(string)

Description

The writeln() method of the HTMLDocument object is used to write a string followed by a newline character to a document stream opened by open(). The string is parsed into the document’s structure model.

Example

Listing 11.87 illustrates the creation of an HTMLDocument using theHTMLDOMImplementation object and then using the writeln() method to write text data to this document.

Listing 11.87 Using the writeln() Method

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
htmlDoc.writeln("<h1>Hello World</h1>");
htmlDoc.close();
// -->
</script>
</html>

HTMLDOMImplementation

JavaScript 1.5+, JScript 5+ Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

The HTMLDOMImplementation object inherits all properties and methods of theDOMImplementation object with a method for creating an HTML document instance. The method for this object is as follows:

Item
Description

createHTMLDocument() Creates an HTML Document and returns it

Example

Listing 11.88 creates a new HTMLDocument object using the createHTMLDocument()method of HTMLDOMImplementation.

Listing 11.88 Creating a HTMLDOMImplementation object


<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var textArea = htmlDoc.createElement("textarea");
textArea.Value = "Here's some text in a TEXTAREA");
// -->
</script>
</html>

HTMLDOMImplementation.createHTMLDocument()

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlDOMImpl.createHTMLDocument(documentTitle);

Description

The createHTMLDocument() method of the HTMLDOMImplementation object creates an HTMLDocument object with the minimal tree made of the following elements: HTML, HEAD, TITLE, and BODY.

The documentTitle parameter names the title of the document to be set as the content of the TITLE element, through a child Text node.

Example

Listing 11.89 creates a new HTMLDocument object using the createHTMLDocument() method of HTMLDOMImplementation.

Listing 11.89 Creating an HTMLDocument Using the createHTMLDocument()

Method


<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var textArea = htmlDoc.createElement("textarea");
textArea.Value = "Here's some text in a TEXTAREA");
// -->
</script>
</html>

HTMLElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

All HTML element objects inherit from this object. The base HTMLElement object represents elements that only expose the HTML core attributes.

These elements are as follows:

HEAD

• special: SUB, SUP, SPAN, BDO

• font: TT, I, B, U, S, STRIKE, BIG, SMALL

• phrase: EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, ACRONYM, ABBR

• list: DD, DT

NOFRAMES, NOSCRIPT

ADDRESS, CENTER

Table 11.10 contains a list of properties for this object.

Table 11.10 Properties of theHTMLElement Object

Image

Example

Listing 11.90 illustrates the creation of a BaseElement object interrogating its id to verify the correct type.

Listing 11.90 Creation of a BaseElement Object and Reading Its id

Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var textAreaObj = htmlDoc.createElement("textarea");
if(textAreaObj.id != "textarea")
 throw new DOMException("implementation error!");
// -->
</script>
</html>

HTMLElement.className

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlElemObj.className

Description

The className property of the HTMLElement object is the class attribute of the element.

Example

Listing 11.91 illustrates the creation of a TextAreaElement object and setting itsclassName property.

Listing 11.91 Creating a TextAreaElement Object and Setting Its


<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var textAreaObj = htmlDoc.createElement("textarea");
textAreaObj.classname = "TextArea";
// -->
</html>

HTMLElement.dir

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlElemObj.dir

Description

The dir property of the HTMLElement object specifies the base direction of directionally neutral text and the directionality of tables.

Example

Listing 11.92 illustrates the setting the dir property of the HTMLElement object.

Listing 11.92 Setting the dir property of HTMLElement


<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var textAreaObj = htmlDoc.createElement("textarea");
textAreaObj.dir = "right";
// -->
</html>

HTMLElement.id

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlElemObj.id

Description

The id property of the HTMLElement object represents the element’s identifier.

Example

Listing 11.93 illustrates the creation of a BaseElement object interrogating its ID to verify the correct type.

Listing 11.93 Reading the id property of HTMLElement


<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var textAreaObj = htmlDoc.createElement("textarea");
if(textAreaObj.id != "textarea")

throw new DOMException("implementation error!");
// -->
</html>

HTMLElement.lang

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlElemObj.lang

Description

The lang property of the HTMLElement object represents the language code defined in RFC 1766, which can be found at http://www.ietf.org.

Example

Listing 11.94 illustrates writing if the lang property of the HTMLElement object.

Listing 11.94 Writing the lang Property


<html>
<script language="JavaScript" type="text/javascript"> <!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var textAreaObj = htmlDoc.createElement("textarea");
textAreaObj.lang = "us/english";
// -->
</html>

HTMLElement.title

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlElemObj.title

Description

The title property of the HTMLElement object is the element’s advisory title.

Example

Listing 11.95 illustrates the creation of a HTMLElement and setting its title.

Listing 11.95 Setting the title Property of the HTMLElement Object


<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var textAreaObj = htmlDoc.createElement("textarea");
texAreaObj.title = "TextArea Element";
// -->
</html>

HTMLFieldSetElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

The HTMLFieldSetElement organizes form controls into logical groups. This object inherits all properties and methods from the HTMLElement object. The property for this object is as follows:

Item

Description

form

The form in which this field set element resides

Example

Listing 11.96 illustrates the creation of HTMLFieldSetElement object

Listing 11.96 Creating an HTMLFieldSetElement Object


<html>
<script language="JavaScript" type="text/javascript">
<!--
var fieldSetObj = formObj.createElement("fieldset");
// -->
</script>
</html>

HTMLFieldSetElement.form

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFormSetObj.form

Description

The form property of the HTMLFieldSetElement returns the FORM element containing this control. Returns Null if this control isn’t within the context of a form.

Example

Listing 11.97 illustrates the creation of an HTMLFieldSetElement using theHTMLFormElement object and then checking its form property.

Listing 11.97 Creating an HTMLFieldSetElement and Getting Its form

Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var fieldSetObj = formObj.createElement("fieldset");
if(fieldSetObj.form.name == "emailForm")

processEmail(fieldSetObj.Form);
// -->
</html>

HTMLFontElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents an HTML Font element. HTMLFontElement inherits all methods and properties of HTMLElement. Table 11.11 contains a list of properties for this object.

Table 11.11 Properties of theHTMLFontElement Object

Image

Example

Listing 11.98 illustrates the creation of an HTMLFontElement using theHTMLBodyElement object.

Listing 11.98 Creating an HTMLFontElement


<html>
<script language="JavaScript" type="text/javascript">
<!--
var fontObj = bodyObj.createElement("font");

// -->
</script>
</html>

HTMLFontElement.color

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFontObj.color

Description

The color property of the HTMLFontElement object represents the font color.

Example

Listing 11.99 illustrates the creation of an HTMLFontElement using theHTMLBodyElement object and then setting its color property.

Listing 11.99 Creating an HTMLBodyElement and Setting Its color Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var fontObj = bodyObj.createElement("font");
fontObj.color = "#FFFFFF";
// -->
</html>

HTMLFontElement.face

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFontObj.face

Description

The face property of the HTMLFontElement object represents the font face identifier.

Example

Listing 11.100 illustrates the creation of an HTMLFontElement using theHTMLBodyElement object and then setting its face property.

Listing 11.100 Creating an HTMLFontElement and Setting Its face Property


<html>
<script language="JavaScript" type="text/javascript">
<!--
var fontObj = bodyObj.createElement("font");
fontObj.face = "courier";
// -->

HTMLFontElement.size

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFontObj.size

Description

The size property of the HTMLFontElement object represents the font size.

Example

Listing 11.101 illustrates the creation of an HTMLFontElement using the HTMLBodyElement object element and then setting its size property.

Listing 11.101 Creating an HTMLFontElement and Setting Its size Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var fontObj = bodyObj.createElement("font");
fontObj.size = 10;
// -->
</script>
</html>

HTMLFormElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

The FORM element encompasses behavior similar to a collection and an element. It provides direct access to the contained input elements as well as the attributes of the form element. This object inherits all methods and properties from HTMLElement. Table 11.12 contains a list of properties and methods for this object.

Table 11.12 Contents of the HTMLFormElement Object

Image

Example

Listing 11.102 illustrates the creation of an HTMLFormElement using the HTMLBodyElement object and then the iteration through its elements property.

Listing 11.102 Creating an HTMLFormElement and Iterating Through Its elements Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
var formObj = bodyObj.createElement("form");
var formElements = formObj.elements;
var i = 0;
while(i < formElements.length) {
    processFormElement(formElements.Index(i));
    i++;
}
// -->
</script>
</html>

HTMLFormElement.acceptCharset

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFormObj.acceptCharset

Description

The acceptCharset property of the HTMLFormElement object is a list of character sets supported by the server.

Example

Listing 11.103 illustrates the creation of an HTMLFormElement using the HTMLBodyElement object and then setting its acceptCharset property.

Listing 11.103 Creating an HTMLFormElement and Setting Its acceptCharset Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
var formObj = bodyObj.createElement("form");
formObj.acceptCharset = "us/english";
// -->
</script>
</html>

HTMLFormElement.action

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFormObj.action

Description

The action property of the HTMLFormElement object is a server-side form handler.

Example

Listing 11.104 illustrates the creation of an HTMLFormElement using the HTMLBodyElement object and then setting its action property.

Listing 11.104 Creating an HTMLFormElement and Setting Its action Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
var formObj = bodyObj.createElement("form");
formObj.action = "http://foo.bar/cgi-bin/processForm.pl";
// -->
</script>
</html>

HTMLFormElement.elements

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFormObj.elements

Description

The elements property of the HTMLFormElement object returns a collection of all control elements in the form.

Example

Listing 11.105 illustrates the creation of an HTMLFormElement using the HTMLBodyElement object and then the iteration through its elements property.

Listing 11.105 Creating an HTMLFormElement and Iterating Through Its elements Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
var formObj = bodyObj.createElement("form");
var formElements = formObj.elements;
var i = 0;
while(i < formElements.length) {
   processFormElement(formElements.item(i));
   i++;
}
// -->
</script>
</html>

HTMLFormElement.enctype

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFormObj.enctype

Description

The enctype property of the HTMLFormElement object is the content type of the submitted form, generally "application/x-www-form-urlencoded".

Example

Listing 11.106 illustrates the creation of an HTMLFormElement using the HTMLBodyElement object and then setting its enctype property.

Listing 11.106 Creating an HTMLFormElement and Setting Its enctype Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
var formObj = bodyObj.createElement("form");
formObj.enctype = "application/x-www-form-urlencoded";
// -->
</script>
</html>

HTMLFormElement.length

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFormObj.length

Description

The length property of the HTMLFormElement object is the number of form controls in the form.

Example

Listing 11.107 illustrates the creation of an HTMLFormElement using the HTMLBodyElement object and then reading its length property.

Listing 11.107 Creating an HTMLFormElement and Reading Its length Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
var formObj = bodyObj.createElement("form");
var formElements = formObj.elements;
var i = 0; 
while(i < formElements.length) {
    processFormElement(formElements.item(i));
    i++;
}
// -->
</script>
</html>

HTMLFormElement.method

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFormObj.method

Description

The method property of the HTMLFormElement object is the HTTP method used to submit form.

Example

Listing 11.108 illustrates the creation of an HTMLFormElement using the HTMLBodyElement object and then setting its method property.

Listing 11.108 Creating an HTMLFormElement and Setting Its method Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
var formObj = bodyObj.createElement("form");
formObj.method = "post";
// -->
</script>
</html>

HTMLFormElement.name

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFormObj.name

Description

The name property of the HTMLFormElement object names the form.

Example

Listing 11.109 illustrates the creation of an HTMLFormElement using the HTMLBodyElement object and then setting its name property.

Listing 11.109 Creating an HTMLFormElement and Setting Its name Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
var formObj = bodyObj.createElement("form");
formObj.name = "checkoutForm";
// -->
</script>
</html>

HTMLFormElement.reset()

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFormObj.reset()

Description

The reset() method of the HTMLFormElement object restores a form element’s default values. It performs the same action as a reset button.

Example

Listing 11.110 illustrates the creation of an HTMLFormElement using the HTMLBodyElement object and then the invocation of its reset() method.

Listing 11.110 Creating an HTMLFormElement and Invoking Its reset() Method

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
var formObj = bodyObj.createElement("form");
formObj.reset();
// -->
</script>
</html>

HTMLFormElement.submit()

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFormObj.submit()

Description

The submit() method of the HTMLFormElement object submits the form. It performs the same action as a submit button.

Example

Listing 11.111 illustrates the creation of an HTMLFormElement using the HTMLBodyElement object and then the invocation of its submit() method.

Listing 11.111 Creating an HTMLFormElement and Invoking Its submit() Method

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
var formObj = bodyObj.createElement("form");
formObj.submit();
// -->
</script>
</html>

HTMLFormElement.target

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFormObj.target

Description

The target property of the HTMLFormElement object is the frame to render the resource in.

Example

Listing 11.112 illustrates the creation of an HTMLFormElement using the HTMLBodyElement object and then setting its target property.

Listing 11.112 Creating an HTMLFormElement and Setting Its target Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var bodyObj = htmlDoc.createElement("body");
var formObj = bodyObj.createElement("form");
formObj.target = "MainFrame";
// -->
</script>
</html>

HTMLFrameElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents an HTML frame element. It is used to create a frame. The HTMLFrameElement inherits all properties and methods from HTMLElement. Table 11.13 contains a list of properties for this object.

Table 11.13 Properties of the HTMLFrameElement Object

Image

Example

Listing 11.113 illustrates the creation of an HTMLFrameElement using the HTMLFrameSetElement object.

Listing 11.113 Creating an HTMLFrameElement

<html>
<script language="JavaScript" type="text/javascript">
<!--
frameSetObj = htmlDoc.createElement("frameset");
var frameObj = frameset.createElement("frame");
// -->
</script>
</html>

HTMLFrameElement.contentDocument

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFrameObj.contentDocument

Description

The contentDocument property of the HTMLFrameElement object is the document this frame contains, if there is one and it is available, or Null otherwise.

Example

Listing 11.114 illustrates reading the contentDocument property of a HTMLFrameElement object.

Listing 11.114 Reading the contentDocument Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDocObj = frameObj.contentDocument;
// -->
</script>
</html>

HTMLFrameElement.frameBorder

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFrameObj.frameBorder

Description

The frameBorder property of the HTMLFrameElement object is the request frame borders.

Example

Listing 11.115 illustrates the creation of an HTMLFrameElement using the HTMLFrameSetElement object and then setting its frameBorder property.

Listing 11.115 Creating an HTMlFrameElement and Setting Its frameBorder Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
frameSetObj = htmlDoc.createElement("frameset");
var frameObj = frameset.createElement("frame");
frameObj.Border = 0;
// -->
</script>
</html>

HTMLFrameElement.longDesc

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFrameObj.longDesc

Description

The longDesc property of the HTMLFrameElement object is the URI designating a long description of this image or frame.

Example

Listing 11.116 illustrates the creation of an HTMLFrameElement using the HTMLFrameSetElement object and then setting its longDesc property.

Listing 11.116 Creating an HTMLFrameElement and Setting Its longDesc Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
frameSetObj = htmlDoc.createElement("frameset");
var frameObj = frameset.createElement("frame");
frameObj.longDesc = "http://foo.bar/framedesc.html";
// -->
</script>
</html>

HTMLFrameElement.marginHeight

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFrameObj.marginHeight

Description

The marginHeight property of the HTMLFrameElement object is the frame margin height, in pixels.

Example

Listing 11.117 illustrates the creation of an HTMLFrameElement using the HTMLFrameSetElement object and then setting its marginHeight property.

Listing 11.117 Creating an HTMLFrameElement and Setting Its marginHeight Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
frameSetObj = htmlDoc.createElement("frameset");
var frameObj = frameset.createElement("frame");
frameObj.marginHeight = 3;
// -->
</script>
</html>

HTMLFrameElement.marginWidth

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFrameObj.marginWidth

Description

The marginWidth property of the HTMLFrameElement object is the frame margin width, in pixels.

Example

Listing 11.118 illustrates the creation of an HTMLFrameElement using the HTMLFrameSetElement object and then setting its marginWidth property.

Listing 11.118 Creating an HTMLFrameElement and Setting Its marginWidth Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
frameSetObj = htmlDoc.createElement("frameset");
var frameObj = frameset.createElement("frame");
frameObj.marginWidth = 3;
// -->
</script>
</html>

HTMLFrameElement.name

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFrameObj.name

Description

The name property of the HTMLFrameElement object is the frame name (object of the target attribute).

Example

Listing 11.119 illustrates the creation of an HTMLFrameElement using the HTMLFrameSetElement object element and then setting its name property.

Listing 11.119 Creating an HTMLFrameElement and Setting Its name Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
frameSetObj = htmlDoc.createElement("frameset");
var frameObj = frameset.createElement("frame");
frameObj.name = "mainframe";
// -->
</script>
</html>

HTMLFrameElement.noResize

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFrameObj.noResize

Description

The noResize property of the HTMLFrameElement object forbids user from resizing frame when true.

Example

Listing 11.120 illustrates the creation of an HTMLFrameElement using the HTMLFrameSetElement object and then setting its noResize property.

Listing 11.120 Creating an HTMLFrameElement and Setting Its noResize Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
frameSetObj = htmlDoc.createElement("frameset");
var frameObj = frameset.createElement("frame");
frameObj.noResize = true;
// -->
</script>
</html>

HTMLFrameElement.scrolling

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFrameObj.scrolling

Description

The scrolling property of the HTMLFrameElement object specifies whether the frame should have scrollbars.

Example

Listing 11.121 illustrates the creation of an HTMLFrameElement using the HTMLFrameSetElement object and then setting its scrolling property.

Listing 11.121 Creating an HTMLFrameElement and Setting Its scrolling Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
frameSetObj = htmlDoc.createElement("frameset");
var frameObj = frameset.createElement("frame");
frameObj.scrolling = false;
// -->
</script>
</html>

HTMLFrameElement.src

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFrameObj.src

Description

The src property of the HTMLFrameElement object is a URI designating the initial frame contents.

Example

Listing 11.122 illustrates the creation of an HTMLFrameElement using the HTMLFrameSetElement object and then setting its src property.

Listing 11.122 Creating an HTMLFrameElement and Setting Its src Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
frameSetObj = htmlDoc.createElement("frameset");
var frameObj = frameset.createElement("frame");
frameObj.src = "http://foo.bar/ ";
// -->
</script>
</html>

HTMLFrameSetElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents an HTML frameset element and is used to create a grid of frames. The HTMLFrameSetElement object inherits all properties and methods from HTMLElement. Table 11.14 contains a list of properties for this object.

Table 11.14 Properties of the HTMLFrameSetElement Object

Image

Example

Listing 11.123 illustrates the creation of an HTMLFrameSetElement using the HTMLDocument object.

Listing 11.123 Creating an HTMLFrameSetElement

<html>
<script language="JavaScript" type="text/javascript">
<!--
frameSetObj = htmlDoc.createElement("frameset");

// -->
</script>
</html>

HTMLFrameSetElement.cols

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFrameSetObj.cols

Description

The cols property of the HTMLFrameSetElement object is the number of columns of frames in the frameset.

Example

Listing 11.124 illustrates the creation of an HTMLFrameSetElement using the HTMLDocument object and then setting its cols property.

Listing 11.124 Creating an HTMLFrameSetElement and Setting Its cols Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
frameSetObj = htmlDoc.createElement("frameset");
frameset.cols = 3;
// -->
</script>
</html>

HTMLFrameSetElement.rows

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlFrameSetObj.rows

Description

The rows property of the HTMLFrameSetElement object is the number of rows of frames in the frameset.

Example

Listing 11.125 illustrates the creation of an HTMLFrameSetElement using the HTMLDocument object element and then setting its rows property.

Listing 11.125 Creating an HTMLFrameSetElement and Setting Its rows Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
frameSetObj = htmlDoc.createElement("frameset");
frameset.rows = 3;
// -->
</script>
</html>

HTMLHeadElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents this document’s header information. This object inherits all methods and properties from the HTMLElement object. The property for this object is as follows:

Item

Description

profile

URI specifying the metadata profile

Example

Listing 11.126 illustrates the creation of an HTMlHeadlElement using the HTMLDocument object.

Listing 11.126 Creating an HTMLHeadElement

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var headElement = htmlDoc.createElement("head");


// -->
</script>
</html>

HTMLHeadElement.profile

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlHeadElemObj.profile

Description

The profile property of the HTMLHeadElement object represents the URI designating a metadata profile.

Example

Listing 11.127 illustrates the creation of an HTMLHeadlElement using the HTMLDocument object element and then setting its profile property.

Listing 11.127 Creating an HTMLHeadElement and Setting Its profile Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var headElement = htmlDoc.createElement("head");
headElement.profile = "http://foo.bar/metaprofile.htm";
// -->
</script>
</html>

HTMLHeadingElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents HTML heading elements H1 to H6. The HTMLHeadingElement

object inherits all properties and methods from the HTMLElement object. The property for this object is as follows:

Item

Description

align

The horizontal alignment for this heading element

Example

Listing 11.128 illustrates the creation of an HTMLHeadingElement using the HTMLBodyElement object element and then setting its align property.

Listing 11.128 Creating an HTMLHeadingElement and Setting Its align Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var headingObj = bodyObj.createElement("heading");
headingObj.align = "left";
// -->
</script>
</html>

HTMLHeadingElement.align

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlHeadingingObj.align

Description

The align property of the HTMLHeadingElement object is the horizontal text alignment.

Example

Listing 11.129 illustrates the creation of an HTMLHeadingElement using the HTMLBodyElement object and then setting its align property.

Listing 11.129 Creating an HTMLHeadingElement and Setting Its align Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var headingObj = bodyObj.createElement("heading");
headingObj.align = "bottom";
// -->
</script>
</html>

HTMLHRElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents an HTML horizontal rule element. The HTMLHRElement inherits all properties and methods from HTMLElement. Table 11.15 contains a list of properties for this object.

Table 11.15 Properties of the HTMLHRElement Object

Image

Example

Listing 11.130 illustrates the creation of an HTMLHRElement using the HTMLBodyElement object and then setting its align property.

Listing 11.130 Creating an HTMLHRElement and Setting Its align Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var hrObj = bodyObj.CreateElement("hr");
hrObj.align = "top";
// -->
</script>
</html>

HTMLHRElement.align

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlHRObj.align

Description

The align property of the HTMLHRElement object aligns the rule on the page.

Example

Listing 11.131 illustrates the creation of an HTMLHRElement using the HTMLBodyElement object and then setting its align property.

Listing 11.131 Creating an HTMLHRElement and Setting Its align Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var hrObj = bodyObj.CreateElement("hr");
hrObj.align = "bottom";
// -->
</html>

HTMLHRElement.noShade

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlHRObj.noShade

Description

The noShade property of the HTMLHRElement object indicates to the user agent that there should be no shading in the rendering of this element.

Example

Listing 11.132 illustrates the creation of an HTMLHRElement using the HTMLBodyElement object and then setting its noShade property.

Listing 11.132 Creating an HTMLHRElement and Setting Its noShade Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var hrObj = bodyObj.CreateElement("hr");
hrObj.noShade = true;
// -->
</script>
</html>

HTMLHRElement.size

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlHRObj.size

Description

The size property of the HTMLHRElement object is the height of the rule.

Example

Listing 11.133 illustrates the creation of an HTMLHRElement using the HTMLBodyElement object and then setting its size property.

Listing 11.133 Creating an HTMLHRElement and Setting Its size Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var hrObj = bodyObj.CreateElement("hr");
hrObj.size = 10;
// -->
</script>
</html>

HTMLHRElement.width

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlHRObj.width

Description

The width property of the HTMLHRElement object is the width of the horizontal rule.

Example

Listing 11.134 illustrates the creation of an HTMLHRElement using the HTMLBodyElement object element and then setting its width property.

Listing 11.134 Creating an HTMLHRElement and Setting Its width Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var hrObj = bodyObj.CreateElement("hr");
hrObj.width = 10;
// -->
</script>
</html>

HTMLHtmlElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents the root of an HTML document. HTMLHtmlElement inherits all properties and methods of the HTMLElement object. The property for this object is as follows:

Item

Description

version

Version information about this document’s DTD

Example

Listing 11.135 illustrates the creation of an HTMlHtmlElement using the HTMLDocument object element.

Listing 11.135 Creating an HTMLHtmlElement

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHtmlDocument("My HTML Doc");
htmlDoc.open();
var htmlElement = htmlDoc.createElement("html");


// -->
</script>
</html>

HTMLHtmlElement.version

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlHtmlElementObj.version

Description

The version property of the HTMLHtmlElement represents version information about the document’s DTD.

Example

Listing 11.136 illustrates the creation of an HTMlHtmlElement using the HTMLDocument

object element and then setting its version property.

Listing 11.136 Creating an HTMLHtmlElement and Setting Its version Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHtmlDocument("My HTML Doc");
htmlDoc.open();
var htmlElement = htmlDoc.createElement("html");
htmlElement.version = "4.0";

// -->
</script>
</html>

HTMLIFrameElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents an HTML internal frame element. The HTMLIFrameElement object inherits all properties and methods of the HTMLElement object. Table 11.16 contains a list of properties for this object.

Table 11.16 Properties of the HTMLIFrameElement Object

Image

Example

Listing 11.137 illustrates the creation of an HTMLIFrameElement using the HTMLBodyElement.

Listing 11.137 Creating an HTMLIFrameElement

<html>
<script language="JavaScript" type="text/javascript">
<!--
var iFrameObj = bodyObj.createElement("iframe");

// -->
</script>
</html>

HTMLIFrameElement.align

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlIFrameObj.align

Description

The align property of the HTMLFrameElement object aligns this object (vertically or horizontally) with respect to its surrounding text.

Example

Listing 11.138 illustrates the creation of an HTMLIFrameElement using the HTMLBodyElement object and then setting its align property.

Listing 11.138 Creating an HTMLIFrameElement and Setting Its align Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var iFrameObj = bodyObj.createElement("iframe");
iFrameObj.align = "top";
// -->
</script>
</html>

HTMLIFrameElement.contentDocument

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlIFrameObj.contentDocument

Description

The contentDocument property of the HTMLIFrameElement object represents the document this frame contains, if there is one and it is available, or Null otherwise.

Example

Listing 11.139 illustrates reading an HTMLIFrameElement's contentDocument property.

Listing 11.139 Reading an HTMLIFrameElement ’s contentDocument Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = iFrameObj.contentDocument;
// -->
</script>
</html>

HTMLIFrameElement.frameBorder

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlIFrameObj.frameBorder

Description

The frameBorder property of the HTMLIFrameElement object requests the frame borders for this object.

Example

Listing 11.140 illustrates the creation of an HTMLIFrameElement using the HTMLBodyElement object and then setting its frameBorder property.

Listing 11.140 Creating an HTMLIFrameElement and Setting Its frameBorder Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var iFrameObj = bodyObj.createElement("iframe");
iFrameObj.frameBorder = 1;
// -->
</script>
</html>

HTMLIFrameElement.height

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlIFrameObj.height

Description

The height property of the HTMLIFrameElement object represents the frame height.

Example

Listing 11.141 illustrates the creation of an HTMLIFrameElement using the HTMLBodyElement object and then setting its height property.

Listing 11.141 Creating an HTMLIFrameElement and Setting Its height Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var iFrameObj = bodyObj.createElement("iframe");
iFrameObj.height = 25;
// -->
</script>
</html>

HTMLIFrameElement.longDesc

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlIFrameObj.longDesc

Description

The longDesc property of the HTMLIFrameElement object represents the URI designating a long description of this image or frame.

Example

Listing 11.142 illustrates the creation of an HTMLIFrameElement using the HTMLBodyElement object and then setting its longDesc property.

Listing 11.142 Creating an HTMLIFrameElement and Setting Its longDesc Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var iFrameObj = bodyObj.createElement("iframe");
iFrameObj.longDesc = "http://foo.bar/desc.html";
// -->
</script>
</html>

HTMLIFrameElement.marginHeight

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlIFrameObj.marginHeight

Description

The marginHeight property of the HTMLIFrameObject represents the frame margin height, in pixels.

Example

Listing 11.143 illustrates the creation of an HTMLIFrameElement using the HTMLBodyElement object and then setting its marginHeight property.

Listing 11.143 Creating an HTMLIFrameElement and Setting the marginHeight Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var iFrameObj = bodyObj.createElement("iframe");
iFrameObj.marginHeight = 4;
// -->
</script>
</html>

HTMLIFrameElement.marginWidth

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlIFrameObj.marginWidth

Description

The marginWidth property of the HTMLIFrameElement represents the frame margin width, in pixels.

Example

Listing 11.144 illustrates the creation of an HTMLIFrameElement using the HTMLBodyElement object and then setting its marginWidth property.

Listing 11.144 Creating an HTMLIFrameElement and Setting the marginWidth Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var iFrameObj = bodyObj.createElement("iframe");
iFrameObj.width = 33;
// -->
</script>
</html>

HTMLIFrameElement.name

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlIFrameObj.name

Description

The name property of the HTMLIFrameElement object represents the frame name (object of the target attribute).

Example

Listing 11.145 illustrates the creation of an HTMLIFrameElement using the HTMLBodyElement object and then setting its name property.

Listing 11.145 Creating an HTMLIFrameElement and Setting Its name Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var iFrameObj = bodyObj.createElement("iframe");
iFrameObj.name = "myframe";
// -->
</script>
</html>

HTMLIFrameElement.scrolling

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlIFrameObj.scrolling

Description

The scrolling property of the HTMLIFrameElement object specifies whether the frame should have scrollbars.

Example

Listing 11.146 illustrates the creation of an HTMLIFrameElement using the HTMLBodyElement object and then setting its scrolling property.

Listing 11.146 Creating an HTMLIFrameElement and Setting Its scrolling Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var iFrameObj = bodyObj.createElement("iframe");
iFrameObj.scrolling = false;
// -->
</script>
</html>

HTMLIFrameElement.src

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlIFrameObj.src

Description

The src property of the HTMLIFrameElement object represent a URI designating the initial frame contents.

Example

Listing 11.147 illustrates the creation of an HTMLIFrameElement using the HTMLBodyElement object and then setting its src property.

Listing 11.147 Creating an HTMLIFrameElement and Setting Its src Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var iFrameObj = bodyObj.createElement("iframe");
iFrameObj.src = "http://foo.bar/";
// -->
</script>
</html>

HTMLIFrameElement.width

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlIFrameObj.width

Description

The width property of the HTMLIFrameElement object represents the frame width.

Example

Listing 11.148 illustrates the creation of an HTMLIFrameElement using the HTMLBodyElement object and then setting its width property.

Listing 11.148 Creating an HTMLIFrameElement and Setting Its width Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var iFrameObj = bodyObj.createElement("iframe");
iFrameObj.width = 100;
// -->
</script>
</html>

HTMLImageElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

Core DOM HTML object.

Description

This object represents an HTML image element. The HTMLImageElement object inherits all methods and properties from the HTMLElement object. Table 11.17 contains a list of properties for this object.

Table 11.17 Properties of the HTMLImageElement Object

Image

Example

Listing 11.149 illustrates the creation of an HTMLImageElement using the HTMLBodyElement object and then setting its lowSrc property.

Listing 11.149 Creating an HTMLImageElement and Setting Its lowSrc Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var imageObj = bodyObj.createElement("img");
imageObj.lowSrc = "http://foo.bar/images/lowfi.jpg";
// -->
</script>
</html>

HTMLImageElement.align

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlImageObj. align

Description

The align property of the HTMLImageElement object aligns this object (vertically or horizontally) with respect to its surrounding text.

Example

Listing 11.150 illustrates the creation of an HTMLImageElement using the HTMLBodyElement object and then setting its align property.

Listing 11.150 Creating an HTMLImageElement and Setting Its align Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var imageObj = bodyObj.createElement("image);
imageObj.align = "top";
// -->
</script>
</html>

HTMLImageElement.alt

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlImageObj. alt

Description

The alt property of the HTMLImageElement object represents alternate text for user agents not rendering the normal content of this element.

Example

Listing 11.151 illustrates the creation of an HTMLImageElement using the HTMLBodyElement object and then setting its alt property.

Listing 11.151 Creating an HTMLImageElement and Setting Its alt Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var imageObj = bodyObj.CreateElment("image);
imageObj.alt = "Can't support images?";
// -->
</script>
</html>

HTMLImageElement.border

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlImageObj. border

Description

The border property of the HTMLImageElement indicates the width of border around image.

Example

Listing 11.152 illustrates the creation of an HTMLImageElement using the HTMLBodyElement object and then setting its border property.

Listing 11.152 Creating an HTMLImageElement and Setting Its border Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var imageObj = bodyObj.createElement("image);
imageObj.border = 1;
// -->
</script>
</html>

HTMLImageElement.height

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlImageObj. height

Description

The height property of the HTMLImageElement object overrides the height of the image.

Example

Listing 11.153 illustrates the creation of an HTMLImageElement using the HTMLBodyElement object element and then setting its height property.

Listing 11.153 Creating an HTMLImageElement and Setting Its height Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var imageObj = bodyObj.createElement("img");
imageObj.height = 12;
// -->
</script>
</html>

HTMLImageElement.hspace

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlImageObj. hspace

Description

The hspace property of the HTMLImageElement object indicates the horizontal space to the left and right of this image.

Example

Listing 11.154 illustrates the creation of an HTMLImageElement using the HTMLBodyElement object and then setting its hspace property.

Listing 11.154 Creating an HTMLImageElement and Setting Its hspace Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var imageObj = bodyObj.createElement("img");
imageObj.hspace = 12;
// -->
</script>

HTMLImageElement.isMap

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlImageObj. isMap

Description

The isMap property of the HTMLImageElement object indicates whether or not to use a server-side image map.

Example

Listing 11.155 illustrates the creation of an HTMLImageElement using the HTMLBodyElement object and then setting its isMap property.

Listing 11.155 Creating an HTMLImageElement and Setting Its isMap Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var imageObj = bodyObj.createElement("img");
imageObj.isMap = false;
// -->
</script>
</html>

HTMLImageElement.longDesc

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlImageObj. longDesc

Description

The longDesc property of the HTMLImageELement object indicates the URI designating a long description of this image or frame.

Example

Listing 11.156 illustrates the creation of an HTMLImageElement using the HTMLBodyElement object and then setting its longDesc property.

Listing 11.156 Creating an HTMLImageElement and Setting Its longDesc Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var imageObj = bodyObj.createElement("img");
imageObj.longDesc = "This is a long description of this image.";
// -->
</script>
</html>

HTMLImageElement.lowSrc

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlImageObj. lowSrc

Description

The lowSrc property of the HTMLImageElement object indicates the URI designating the source of this image for low-resolution output.

Example

Listing 11.157 illustrates the creation of an HTMLImageElement using the HTMLBodyElement object element and then setting its lowSrc property.

Listing 11.157 Creating an HTMLImageElement and Setting Its lowSrc Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var imageObj = bodyObj.createElement("img");
imageObj.lowSrc = "http://foo.bar/images/lowfi.jpg";
// -->
</script>
</html>

HTMLImageElement.src

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlImageObj. src

Description

The src property of the HTMLImageElement object indicates the URI designating the source of this image.

Example

Listing 11.158 illustrates the creation of an HTMLImageElement using the HTMLBodyElement object element and then setting its src property.

Listing 11.158 Creating an HTMLImageElement and Setting Its src Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var imageObj = bodyObj.createElement("img");
imageObj.src = "http://foo.bar/images/foo.jpg";
// -->
</script>
</html>

HTMLImageElement.useMap

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlImageObj. useMap

Description

The useMap property of the HTMLImageElement object indicates the name of the client-side image map to use.

Example

Listing 11.159 illustrates the creation of an HTMLImageElement using the HTMLBodyElement object element and then setting its useMap property.

Listing 11.159 Creating an HTMLImageElement and Setting Its useMap Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var imageObj = bodyObj.createElement("img");
imageObj.useMap = "myClientMap";
// -->
</script>
</html>

HTMLImageElement.vspace

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlImageObj. vspace

Description

The vspace property of the HTMLImageElement object indicates the vertical space above and below this image.

Example

Listing 11.160 illustrates the creation of an HTMLImageElement using the HTMLBodyElement object and then setting its vspace property.

Listing 11.160 Creating an HTMLImageElement and Setting Its vspace Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var imageObj = bodyObj.createElement("img");
imageObj.vspace = 2;
// -->
</script>
</html>

HTMLImageElement.width

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlImageObj. width

Description

The width property of the HTMLImageElement object overrides width of the image.

Example

Listing 11.161 illustrates the creation of an HTMLImageElement using the HTMLBodyElement object and then setting its width property.

Listing 11.161 Creating an HTMLImageElement and Setting Its width Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var imageObj = bodyObj.createElement("img");
imageObj.width = 23;
// -->
</script>
</html>

HTMLInputElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

Core DOM HTML object.

Description

This object represents a form control used for text input.

This object inherits all methods and properties of the HTMLElement object.

Table 11.18 contains a list of properties and methods for this object.

Table 11.18 Contents of the HTMLInputElement Object

Image

Example

Listing 11.162 illustrates the creation of an HTMLInputElement using the HTMLFormElement.

Listing 11.162 Creating an HTMLInputElement

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
// -->
</script>
</html>

HTMLInputElement.accept

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. accept

Description

The accept property of the HTMLInputElement object is a comma-separated list of content types that a server processing this form will handle correctly.

Example

Listing 11.163 illustrates the accept property of an HTMLInputElement object.

Listing 11.163 Setting the accept Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
inputObj.accept = "text/html";
// -->
</script>
</html>

HTMLInputElement.accessKey

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. accessKey

Description

The accessKey property of the HTMLInputElement object is a single character access key to give access to the form control.

Example

Listing 11.164 illustrates the creation of an HTMLInputElement using the HTMLFormElement object element and then setting its accessKey property.

Listing 11.164 Creating an HTMLInputElement and Setting Its accessKey Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.accessKey = "A";
// -->
</html>

HTMLInputElement.align

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. align

Description

The align property of the HTMLInputElement object aligns this object (vertically or horizontally) with respect to its surrounding text.

Example

Listing 11.165 illustrates the creation of an HTMLInputElement using the HTMLFormElement object and then setting its align property.

Listing 11.165 Creating an HTMLInputElement and Setting Its align Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.align = "left";
// -->
</script>
</html>

HTMLInputElement.alt

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. alt

Description

The alt property of the HTMLInputElement object is alternate text for user agents not rendering the normal content of this element.

Example

Listing 11.166 illustrates the creation of an HTMLInputElement using the HTMLFormElement object element and then setting its alt property.

Listing 11.166 Creating an HTMLInputElement and Setting Its alt Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.alt = "Input here!";
// -->
</html>

HTMLInputElement.blur()

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. blur()

Description

The blur() method of the HTMLInputElement object removes keyboard focus from this element.

Example

Listing 11.167 illustrates the creation of an HTMLInputElement using the HTMLFormElement object and then the invocation of its blur() method.

Listing 11.167 Creating an HTMLInputElement and Invoking Its blur() Method

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.blur();
// -->
</script>
</html>

HTMLInputElement.checked

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. checked

Description

The checked property of the HTMLInputElement object is relevant when the type attribute of the element has the value "Radio" or "Checkbox", this represents the current state of the form control, in an interactive user agent. Changes to this attribute change the state of the form control, but do not change the value of the HTML value attribute of the element.

Example

Listing 11.168 illustrates the creation of an HTMLInputElement using the HTMLFormElement object and then setting its checked property.

Listing 11.168 Creating an HTMLInputElement and Setting Its checked Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.Type = "checkbox";
input.checked = false;
// -->
</script>
</html>

HTMLInputElement.click()

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. click()

Description

The click() method of the HTMLInputElement object simulates a mouse click. For INPUT elements whose type attribute has one of the following values: "Button", "Checkbox", "Radio", "Reset", or "Submit".

Example

Listing 11.169 illustrates the creation of an HTMLInputElement using the HTMLFormElement object and then the invocation of its click() method.

Listing 11.169 Creating an HTMLInputElement and Invoking Its click() Method

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.type = "checkbox";
inputObj.click();
// -->
</html>

HTMLInputElement.defaultChecked

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. defaultChecked

Description

The defaultChecked property of the HTMLInputElement object is relevant when type has the value "Radio" or "Checkbox", this represents the HTML checked attribute of the element. The value of this attribute doesn’t change if the state of the corresponding form control, in an interactive user agent, changes. Changes to this attribute, however, resets the state of the form control.

Example

Listing 11.170 illustrates the creation of an HTMLInputElement using the HTMLFormElement object and then setting its defaultChecked property.

Listing 11.170 Creating an HTMLInputElement and Setting Its defaultChecked Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.type = "checkbox";
inputObj.defaultChecked = true;
// -->
</html>

HTMLInputElement.defaultValue

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. defaultValue

Description

The defaultValue property of the HTMLInputElement object is relevant when the type attribute of the element has the value "Text", "File", or "Password", this represents the HTML value attribute of the element. The value of this attribute doesn’t change if the contents of the corresponding form control, in an interactive user agent, changes. Changing this attribute, however, resets the contents of the form control.

Example

Listing 11.171 illustrates the creation of an HTMLInputElement using the HTMLFormElement object and then setting its defaultValue property.

Listing 11.171 Creating an HTMLInputElement and Setting Its defaultValue Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
input.type = "Password";
input.defaultValue = "";
// -->
</script>
</html>

HTMLInputElement.disabled

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. disabled

Description

The disabled property of the HTMLInputElement object is used to disable the input object instance.

Example

Listing 11.172 illustrates the creation of an HTMLInputElement using the HTMLFormElement object and then setting its disabled property.

Listing 11.172 Creating an HTMLInputElement and Setting Its disabled Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.disabled = true;
// -->
</html>

HTMLInputElement.focus()

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. focus()

Description

The focus() method of the HTMLInputElement object gives keyboard focus to this element.

Example

Listing 11.173 illustrates the creation of an HTMLInputElement using the HTMLFormElement object element and then the invocation of its focus() method.

Listing 11.173 Creating an HTMLInputElement and Invoking Its focus() Method

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.focus();
// -->
</html>

HTMLInputElement.form

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. Form

Description

The form property of the HTMLInputElement object returns the FORM element containing this control. Returns Null if this control isn’t within the context of a form.

Example

Listing 11.174 illustrates the creation of an HTMLInputElement using the HTMLFormElement object and then reading its form property.

Listing 11.174 Creating an HTMLInputElement and Reading Its form Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
if(inputObj.form.name == "emailForm")
    processEmailForm(inputObj.form);
// -->
</html>

HTMLInputElement.maxLength

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. maxLength

Description

The maxLength property of the HTMLInputElement object is the maximum number of characters for text fields, when type has the value "Text" or "Password".

Example

Listing 11.175 illustrates the creation of an HTMLInputElement using the HTMLFormElement object and then setting its maxLength property.

Listing 11.175 Creating an HTMLInputElement and Setting Its maxlength Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.type = "text";
inputObj.maxLength = 25;
// -->
</html>

HTMLInputElement.name

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. name

Description

The name property of the HTMLInputElement object is the form control or object name when submitted with a form.

Example

Listing 11.176 illustrates the creation of an HTMLInputElement using the HTMLFormElement object and then setting its name property.

Listing 11.176 Creating an HTMLInputElement and Setting name Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.name = "address";
// -->
</html>

HTMLInputElement.readOnly

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. readOnly

Description

The readOnly property of the HTMLInputElement object indicates that this control is read-only. Relevant only when type has the value "Text" or "Password".

Example

Listing 11.177 illustrates the creation of an HTMLInputElement using the HTMLFormElement object element and then setting its readOnly property.

Listing 11.177 Creating an HTMLInputElement and Setting Its readOnly Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.type = "text";
inputObj.value = "readonly field";
inputObj.readOnly = true;
// -->
</html>

HTMLInputElement.select()

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. select()

Description

The select() method of the HTMLInputElement object selects the contents of the text area. For INPUT elements whose type attribute has one of the following values: "Text", "File", or "Password".

Example

Listing 11.178 illustrates the creation of an HTMLInputElement using the HTMLFormElement object and then the invocation of its select() method.

Listing 11.178 Creating an HTMLInputElement and Invoking Its select() Method

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.type = "text";
inputObj.value = "foo bar";
inputObj.select();
// -->
</html>

HTMLInputElement.size

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. size

Description

The size property of the HTMLInputElement object indicates the size information. The precise meaning is specific to each type of field.

Example

Listing 11.179 illustrates the creation of an HTMLInputElement using the HTMLFormElement object and then setting its size property.

Listing 11.179 Creating an HTMLInputElement and Setting Its size Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.type = "text";
inputObj.size = 25;
// -->
</html>

HTMLInputElement.src

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. src

Description

The src property of the HTMLInputElement object is relevant when the type attribute has the value "Image", this attribute specifies the location of the image to be used to decorate the graphical submit button.

Example

Listing 11.180 illustrates the creation of an HTMLInputElement using the HTMLFormElement object element and then setting its src property.

Listing 11.180 Creating an HTMLInputElement and Setting Its src Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.type = "image";
inputObj.src = "http://foo.bar/images/foo.jpg";
// -->
</html>

HTMLInputElement.tabIndex

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. tabIndex

Description

The tabInded property of the HTMLInputElement object is the index that represents the element’s position in the tabbing order.

Example

Listing 11.181 illustrates the creation of an HTMLInputElement using the HTMLFormElement object and then setting its tabIndex property.

Listing 11.181 Creating an HTMLInputElement and Setting Its tabIndex Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.type = "text";
inputObj.tabIndex = 1;
// -->
</html>

HTMLInputElement.type

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. type

Description

The type property of the HTMLInputElement object is the type of control created.

Example

Listing 11.182 illustrates the creation of an HTMLInputElement using the HTMLFormElement object element and then setting its type property.

Listing 11.182 Creating an HTMLInputElement and Setting Its type Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.type = "text";
// -->
</html>

HTMLInputElement.useMap

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. useMap

Description

The useMap property of the HTMLInputElement object indicates the name of the client-side image map to use.

Example

Listing 11.183 illustrates the creation of an HTMLInputElement using the HTMLFormElement object and then setting its useMap property.

Listing 11.183 Creating an HTMLInputElement and Setting Its useMap Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.type = "image";
inputObj.useMap = "mymap";
// -->
</html>

HTMLInputElement.value

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

htmlInputObj. value

Description

The value property of the HTMLInputElement object is relevant when the type attribute of the element has the value "Text", "File", or "Password", this represents the current contents of the corresponding form control, in an interactive user agent. Changing this attribute changes the contents of the form control, but doesn’t change the value of the HTML value attribute of the element. When the type attribute of the element has the value "Button", "Hidden", "Submit", "Reset", "Image", "Checkbox", or "Radio", this represents the HTML value attribute of the element.

Example

Listing 11.184 illustrates the creation of an HTMLInputElement using the HTMLFormElement object and then setting its value property.

Listing 11.184 Creating an HTMLInputElement and Setting Its value Property

<html>
<script language="JavaScript" type="text/javascript">
<!--
var inputObj = formObj.createElement("input");
inputObj.type = "reset";
inputObj.value = "Clear form values";
// -->
</html>

HTMLIsIndexElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

Syntax

Core DOM HTML object.

Description

This element is used for single-line text input. HTMLIsIndexElement inherits all methods and properties from HTMLElement. Table 11.19 contains a list of properties for this object.

Table 11.19 Properties of HTMLIsIndexElement Object

Image

Example

Listing 11.185 illustrates the creation of an HTMlIsIndexElement using the HTMLDocument object.

Listing 11.185 Creating an HTMLIsIndexElement

<html>
<script language="JavaScript" type="text/javascript">
<!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument("My HTML Doc");
htmlDoc.open();
var isIndexElement = htmlDoc.createElement("isindex");

}
</html>

HTMLIsIndexElement.form

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlIsIndexObj.form

Description

The form property of the HTMLIsIndexElement object returns the FORM element containing this control. Returns Null if this control isn’t within the context of a form.

Example

Listing 11.186 illustrates the creation of an HTMLIsIndexElement using the HTMLFormElement object element and then reading its form property.

Listing 11.186 Creating an HTMLIsIndexElement and Reading Its form

<html>
<script language="JavaScript" type="text/javascript">
 <!--
var htmlDoc = HTMLDOMImplementation.createHtmlDocument("My HTML Doc");
 htmlDoc.open();
var isIndexElement =htmlDoc.createElement("isIndex");
 if(isIndexElement.form == "emailForm")
  processIsIndex(isIndexElement);
}
 // -->
 </script>

var isIndexElement = htmlDoc.createElement("isIndex");
</html>

HTMLIsIndexElement.prompt

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

htmlIsIndexObj.prompt

Description

The prompt property of the HTMLIsIndexElement object is the prompt message.

Example

Listing 11.187 illustrates the creation of an HTMlIsIndexElement using the HTMLDocument object element and then setting its prompt properties.

Listing 11.187 Creating an HTMLIsIndexElement and Setting Its prompt Property

<html>
 <script language=”JavaScript”type=” text/javascript”> <
!--
var htmlDoc = HTMLDOMImplementation.createHTMLDocument(“My HTML Doc”);
htmlDoc.open();
 var  isIndexElement = htmlDoc.createElement(“isindex”);
isIndexElement.prompt = “prompt”;
}
</script>
</html>

HTMLLabelElement

JavaScript 1.5+, JScript 5+

Nav6+, IE5+

 

Syntax

Core DOM HTML object.

Description

This object represents an HTML form field text label. This object inherits all methods and properties of the HTMLElement object. Table 11.20 contains a list of properties for this object.

Table 11.20 Properties of HTMLLabelElement Object

Image

Example

Listing 11.188 illustrates the creation of an HTMLLabelElement using the HTMLFormElement object.

Listing 11.188 Creating an HTMLLabelElement

<html>
<script language="JavaScript" type="text/javascript"> <
!--
var labelObj = formObj.createElement("label");

// -->
</html>

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.234.62