DHTML Object Model…

After reading “About the DHTML Object Model (DOM)” it gave me insight into what happens when the DOM is implemented. Basically this model allows for specific HTML elements to be programmed. Each element can have it’s own script behind it to allow for user interaction.

The model focuses on collections of elements.  There are 3 different types of collections:

1. All: Contains all elements that are beneath that element in the hierarchy

2. Parent: Element directly above a child element

3. Child: Direct decedent of an element


Internet Explorer supports the all collection whereas the W3C standard uses the getElementById() method. Describe the difference this makes to accessing a particular HTML element in JavaScript.

The following document object properties are not supported in the W3C Document Object Model:

  • document.layers[]
  • id_attribute_value
  • document.all
  • document.all.id_attribute_value
  • document.all[id_attribute_value]

Scripts that use these properties will not execute in Firefox, Camino, Seamonkey or other standards-compliant browsers.  So that these properties do execute the W3C access attributes and access methods should be used. These are supported by internet explorer too.

IE-specific ways to access elements W3C web standards replacements
id_attribute_value document.getElementById(id_attribute_value)
document.all.id_attribute_value document.getElementById(id_attribute_value)
document.all[id_attribute_value] document.getElementById(id_attribute_value)
FormName.InputName.value document.forms[“FormName”].InputName.value or
document.forms[“FormName”].elements[“InputName”].value
InputName.value document.forms[“FormName”].InputName.value or
document.forms[“FormName”].elements[“InputName”].value
FormCtrlName document.forms[“FormName”].FormCtrlName or
document.forms[“FormName”].elements[“FormCtrlName”]
document.forms(0) document.forms[0]

What is the difference between the keypress and keydown events?

Onkeypress: Presses and releases a key (full down and up cycle). however, if a key is held down, multiple onkeypress events are fired.

Onkeydown: presses a key. Only a single event is fired, even if they key  is held down.

What is meant by event bubbling?

Event bubbling makes it easier for the HTML author to handle events. It allows for multiple common actions to be handled centrally. It reduces the amount of overall code and code changes required to update a document.

How do you cancel an event?

If an event is not canceled it bubbles through the document to the parent element unless the event is canceled. To cancel set the                  “window.event.cancelBubble=true;”            in the event handler.

Leave a comment

Filed under Uncategorized

Leave a comment