1k DHTML API - Usage

All versions of the 1k DHTML API define two global variables (defining them globally takes up less space): d (a reference to the document object) and l (a boolean indicating if the browser is Netscape 4.x). If you redefine these variables in your own code, then the API will fail to work. So don't.

All versions of the 1k DHTML API (except subsets) define the following functions:

gE()

Synopsis

gE(elementId)

Arguments

elementId

The id of an HTML element.

Returns

A reference to the named HTML element (even nested elements in NS4). This reference is used by the other functions.

Description

gE() is short for "get element" and is the core method of the 1k DHTML API. In order to perform DHTML actions using the API on an HTML element, gE() must be called first to get a reference to the element. This reference is used as the first argument to any other function defined in the API.

sE()

Synopsis

sE(elementReference)

Arguments

elementReference

The reference to the HTML element returned by gE().

Returns

Nothing.

Description

sE() is short for "show element" and sets the visibility CSS property to inherit. Note that this is different than visible which would mean that an element would become visible even if it's parent element is invisible. Instead, the visibility of the element will depend on it's parent's visibility (which is probably what you want 99% of the time).

hE()

Synopsis

hE(elementReference)

Arguments

elementReference

The reference to the HTML element returned by gE().

Returns

Nothing.

Description

hE() is short for "hide element" and sets the visibility CSS property to hidden.

sZ()

Synopsis

sZ(elementReference, zIndex)

Arguments

elementReference

The reference to the HTML element returned by gE().

zIndex

The positive integer z-index value to assign to the element.

Returns

Nothing.

Description

sZ() is short for "set z-index" and sets the z-index CSS property to the specified value. For cross-browser consistence, use only positive integer values.

sX()

Synopsis

sX(elementReference, leftPixels)

Arguments

elementReference

The reference to the HTML element returned by gE().

leftPixels

The new left position of the HTML element measured in the number of pixels from the left edge of the positioning parent to the left edge of the HTML element.

Returns

Nothing.

Description

sX() is short for "set x position" and sets the left CSS property to the specified value assuming a length measurement of pixels. This is measured with respect to the left edge of the HTML element's positioning parent. The positioning parent is the nearest parent with its position css property set to absolute or relative. If there are no such parents, the document is used as the positioning parent (ie, top and left are measured from the top-left corner of the document).

sY()

Synopsis

sY(elementReference, topPixels)

Arguments

elementReference

The reference to the HTML element returned by gE().

topPixels

The new top position of the HTML element measured in the number of pixels from the top edge of the positioning parent to the top edge of the HTML element.

Returns

Nothing.

Description

sY() is short for "set y position" and sets the top CSS property to the specified value assuming a length measurement of pixels. This is measured with respect to the top edge of the HTML element's positioning parent. The positioning parent is the nearest parent with its position css property set to absolute or relative. If there are no such parents, the document is used as the positioning parent (ie, top and left are measured from the top-left corner of the document).

sW()

Synopsis

sW(elementReference, widthPixels)

Arguments

elementReference

The reference to the HTML element returned by gE().

widthPixels

The new width of the HTML element measured in pixels.

Returns

Nothing.

Description

sW() is short for "set width" and sets the width CSS property to the specified number of pixels.

sH()

Synopsis

sH(elementReference, heightPixels)

Arguments

elementReference

The reference to the HTML element returned by gE().

heightPixels

The new height of the HTML element measured in pixels.

Returns

Nothing.

Description

sH() is short for "set height" and sets the height CSS property to the specified number of pixels.

sC()

Synopsis

sC(elementReference, topPixels, rightPixels, bottomPixels, leftPixels)

Arguments

elementReference

The reference to the HTML element returned by gE().

topPixels

The top position of the clipping on the HTML element measured in pixels.

rightPixels

The right position of the clipping on the HTML element measured in pixels.

bottomPixels

The bottom position of the clipping on the HTML element measured in pixels.

leftPixels

The left position of the clipping on the HTML element measured in pixels.

Returns

Nothing.

Description

sC() is short for "set clip" and sets the clip CSS property to the specified values in the format rect(topPixelspx rightPixelspx bottomPixelspx leftPixelspx). Not supported in IE4.0 Mac and Opera 6 and below.

wH()

Synopsis

wH(elementReference, newContents)

Arguments

elementReference

The reference to the HTML element returned by gE().

newContents

The new HTML content of the HTML element as a string.

Returns

Nothing.

Description

wH() is short for "write HTML" and clears the current content of the element and replaces it with new HTML content. Buggy in IE4.x Mac. Not supported in Opera 6 and below.

More about this script

Related to this script

Licensing

This script is released under a Creative Commons License.