spanNN 6 IE 4 DOM 1  

  

The span object reflects the span element. This element is used primarily as an arbitrary container for assigning styles to inline content elements. You might say that it is the quintessential generic element object. In Navigator 4, a span object that is given a position style is treated very much like a layer object for scripting purposes.

 
HTML Equivalent
 
<span>
 
Object Model Reference
 
[window.]document.getElementById("elementID")
 
Object-Specific Properties

None.

 
Object-Specific Methods

None.

 
Object-Specific Event Handler Properties

None.

blur( )NN 2 IE 3 DOM 1  

Removes focus from the current object, at which time the object's onblur event fires. Note that the range of elements capable of focus and blur (both the event and method) is limited in all browsers except for more recent versions of IE (see the shared tabindex attribute in Chapter 8). Most reliably for backward compatibility, apply the blur( ) method to blatantly focusable elements, such as text input and textarea elements. Assigning the attribute onfocus="this.blur( );" to a text input element, for instance, is a crude but effective backward-compatible way to largely disable a field for browsers that do not provide genuine element disabling.

 

Use blur( ) and focus( ) methods in moderation on the same page. You can inadvertently trigger endless loops of blurring and focusing if alert dialog boxes are involved along the way. Moreover, be aware that when you invoke the blur( ) method on one object, some other object (perhaps the window object) receives an onfocus event.

 
Parameters

None.

 
Returned Value

None.

filters[ ]NN n/a IE 4 DOM n/a  

  

Returns an array of all filter objects contained by the current element. Applies only to the following element objects: bdo, body, button, div, fieldset, img, input, marquee, rt, ruby, span, table, td, textarea, and th. See the filter object for referencing syntax.

 
Value

Array of filter object references.

 
Default

Array of length zero.

focus( )NN 2 IE 3 DOM 1  

Gives focus from the current object, at which time the object's onfocus event fires. Note that the range of elements capable of focus and blur (both the event and method) is limited in all browsers except for more recent versions of IE (see the shared tabindex attribute in Chapter 8). Most reliably for backward compatibility, apply the focus( ) method to blatantly focusable elements, such as text input and textarea elements.

 

To give a text box focus and pre-select all the text in the box, use the sequence of focus( ) and select( ) methods on the element. If this sequence is to occur after windows change (such as after an alert dialog box closes), place the methods in a separate function, and invoke this function through the setTimeout( ) method following the alert( ) method for the dialog. This allows IE/Windows to sequence statement execution correctly.

 
Parameters

None.

 
Returned Value

None.

scrollLeft, scrollTopNN 7 IE 4 DOM n/a  

Read/Write  

Provide the distance in pixels between the actual left or top edge of the element's physical content and the left or top edge of the visible portion of the content. Setting these properties allows you to use a script to adjust the scrolling of content within a scrollable container, such as text in a textarea element or an entire document in the browser window or frame. When the content is not scrolled, both values are zero. Setting the scrollTop property to 15 scrolls the document upward by 15 pixels in the window; the scrollLeft property is unaffected unless explicitly changed. The property values change as the user adjusts the scrollbars. This is important for some event-driven positioning tasks in IE for Windows because the coordinate system for event offset measurements are with respect to the visible area of a page in the browser window. You must add document.body scrolling factors to align event coordinates with body content positions (see the element dragging example in Chapter 6). Starting with IE 5 for Windows, the scrollLeft and scrollTop properties are available for all HTML element objects, but values for unscrollable elements are zero.

 
Example
 
document.body.scrollTop = 40;
 
Value

Positive integer or zero.

 
Default

0