Home | Community | Developer's Paradise | Jobs
User Groups | Site Tools | Site Information | Search

Book/Chapter 9
Preview
/

About

 

Part I - HTML and Scripting
Overview of HTML and CSS
Fundamentals of HTML Scripting
Dynamic HTML Event Model
Programming the Browser Window
Window and Frame Management

 
Part II - Document Structure
The HTML Document
Programming Element Collections
Scripts and Elements
Scripting Individual Elements
Forms and Intrinsic Controls
 

Part III - Dynamic Styles and Animation
Dynamic Styles
Dynamic Positioning

 

Part IV - Dynamic Content
Dynamic Content
User Selection and Editing
Data Binding with HTML

 


Inside Dynamic HTML

Inside Dynamic HTML Book Cover

Order Now
from
Amazon.com

Inside Dynamic HTML
Microsoft Programmers Series

Chapter 9: Scripting Individual Elements


Previous Section:
Programming the Marquee Element

Programming the Object Element

The Object element allows you to include controls and applets that extend the browser. For example, you can create objects to embed graphs or even other documents directly into the document. An object may have its own properties, methods, and events, which the Object element exposes to scripts in the same way that it exposes its own members.

Handling Property Conflicts

A conflict can occur between the object's members and the members of a generic Object element. For example, if the object exposes an id property, it will collide with the id property exposed on the Object element. When this conflict occurs, referencing the id property references the element's version, not the object's. For referencing the object's version of the id property, all object elements expose an object property. This property returns access to the embedded object's members, as shown in the following code.

document.all.myObject.id         // HTML element's id property
document.all.myObject.object.id  // Embedded object's id property

Alternative HTML

The Object element can contain HTML code that is displayed in browsers that do not support the Object element. The down-level contents are exposed as an altHTML property of the Object element in HTML.

The altHTML property can be used to provide contents to the user if the object fails to install. If the object fails to install, the alternative contents replace the object on the page. In the following code, the value of the Object element's altHTML property is the Paragraph element (the <P> and </P> tags and the text between):

<OBJECT CLASSID="java:myClass">
   <PARAM NAME="color" VALUE="red">
   <P>
      Either your browser does not support the Object element or an 
      error occurred while downloading the object.
   </P>
</OBJECT>

Object Events

An object can fire its own custom events. You can bind a handler to such an event using the <SCRIPT FOR= EVENT= > syntax or a language-dependent mechanism, but not using an attribute in the element's tag. The Object element exposes attributes for only those events that are predefined, not for events that the embedded object may fire.

Objects that expose standard events such as mouse and keyboard events can also take part in event bubbling. The object itself fires its standard event, followed by the browser firing the event on every parent element. Generic event handlers for standard events can test whether they originated in an object.


Next Section:
Programming the Table Element

© 1997-98 InsideDHTML.com, LLC. All rights reserved.