JavaScript DOM Utilities

I have written a few utilities to work with the DOM in Mozilla. You may see a text version of that file here. You may also get it by downloading this entire set of pages as a gzipped tar file or as a zip file.

Below is a listing of the function names, preceded with a brief commentary of what each one does. You may see them in action on the next page.

/*
 * Browser version snooper; determines your browser
 * (Navigator 4, Navigator 6, or Internet Explorer 4/5)
 */
function setBrowser()

/*
 *
 * Given a selector string, return a style object
 * by searching through stylesheets. Return null if
 * none found
 *
 */
function getStyleBySelector( selector )

/*
 *
 * Given an id and a property (as strings), return
 * the given property of that id.  Navigator 6 will
 * first look for the property in a tag; if not found,
 * it will look through the stylesheet.
 *
 * Note: do not precede the id with a # -- it will be
 * appended when searching the stylesheets
 *
 */
function getIdProperty( id, property )

/*
 *
 * Given an id and a property (as strings), set
 * the given property of that id to the value provided.
 *
 */
function setIdProperty( id, property, value )

/*
 *
 * Move a given id to position (xValue, yValue)
 * In Navigator 6 and IE 4/5, length units are preserved.
 *
 */
function moveIdTo( id, x, y )

/*
 *
 * Move a given id to (currentX + xValue, currentY + yValue)
 * In Navigator 6 and IE 4/5, length units are preserved.
 *
 */
function moveIdBy( id, x, y)

/*
 *
 * Retrieve background color for a given id.
 * The value returned will be in hex format (#rrggbb)
 *
 */ 
function getBackgroundColor( id )

/*
 *
 * Return a division's document
 * 
 */
function getDocument( divName )

  JavaScript Access Example  Index Utilities Example