:: Documentation >> Reference >>

Active.System.HTML

Generic base class for building and manipulating HTML markup.

Objects, which have visual representation, are most likely subclasses of this generic HTML class. It provides a set of functions to define attributes, inline styles, stylesheet selectors, DOM events and inner HTML content either as static properties or calls to the object’s methods. Direct or implicit call to ‘toString’ method returns properly formatted HTML markup string, which can be used in document.write() call or assigned to the page innerHTML property.

The two-way linking between original javascript object and it’s DOM counterpart is maintained through the use of unique ID for each object. This allows forwarding DOM events back to the proper javascript master object and, if necessary, updating the correct piece of HTML on the page.

Method Summary

elementReturns a reference to the HTML element.
getAttributeReturns HTML attribute.
getClassReturns CSS selector.
getContentReturns static HTML content.
getEventReturns HTML event handler.
getIdReturns unique ID for the object.
getStyleReturns inline CSS attribute.
getTagReturns HTML tag for the object.
refreshUpdates HTML on the page.
setAttributeSets HTML attribute.
setClassSets CSS selector.
setContentSets static HTML content.
setEventSets HTML event handler.
setIdSets ID string for an element.
setStyleSets inline CSS attribute.
setTagSets HTML tag for the object.
toStringReturns HTML markup string for the object.

Method Details

element

Returns a reference to the HTML element.

Syntax

object.element();

Returns

Reference to the HTML element

Remarks

This function returns null if it is called before writing the object to the page.

getAttribute

Returns HTML attribute.

Syntax

object.getAttribute(name);

Parameters

nameStringHTML attribute name.

Returns

HTML attribute value.

getClass

Returns CSS selector.

Syntax

object.getClass(name);

Parameters

nameStringSelector name.

Returns

Selector value.

getContent

Returns static HTML content.

Syntax

object.getContent(name);

Parameters

nameStringcontent name.

Returns

content object or function.

getEvent

Returns HTML event handler.

Syntax

object.getEvent(name);

Parameters

nameStringHTML event name.

Returns

HTML event handler.

getId

Returns unique ID for the object.

Syntax

object.getId();

Returns

Unique ID string.

getStyle

Returns inline CSS attribute.

Syntax

object.getStyle(name);

Parameters

nameStringCSS attribute name.

Returns

CSS attribute value.

getTag

Returns HTML tag for the object.

Syntax

object.getTag();

Returns

HTML tag string

refresh

Updates HTML on the page.

Syntax

object.refresh();

setAttribute

Sets HTML attribute.

Syntax

object.setAttribute(name, value);

Parameters

nameStringHTML attribute name.
valueString/FunctionHTML attribute value.

setClass

Sets CSS selector.

Syntax

object.setClass(name, value);

Parameters

nameStringSelector name.
valueString/FunctionSelector value.

Remarks

The selector string is composed from the three parts - the prefix ('active'), the name and the value, separated by the '-' character. Normally the object class string consists of several selectors separated by space.

Selector values are stored and inherited separately within the object. This function allows easy access to single selector value without parsing the whole class string.

The following example adds 'active-template-list' stylesheet selector to the object class.

Example

obj.setClass("template", "list");

setContent

Sets static HTML content.

Syntax

object.setContent(name, value);

Parameters

nameStringcontent name.
valueObject/String/Functionstatic content.

setEvent

Sets HTML event handler.

Syntax

object.setEvent(name, value);

Parameters

nameStringHTML event name.
valueString/FunctionHTML event handler.

setId

Sets ID string for an element.

Syntax

object.setId(id);

Parameters

idStringNew ID.

setStyle

Sets inline CSS attribute.

Syntax

object.setStyle(name, value);

Parameters

nameStringCSS attribute name.
valueString/FunctionCSS attribute value.

setTag

Sets HTML tag for the object.

Syntax

object.setTag(tag);

Parameters

tagStringThe new tag.

Remarks

By default each HTML object is a DIV tag. This function allows to change the tag string.

Example

obj.setTag("SPAN");

toString

Returns HTML markup string for the object.

Syntax

object.toString();

Returns

HTML string.

Remarks

Direct or implicit call to ‘toString’ method returns properly formatted HTML markup string, which can be used in document.write() call or assigned to the page innerHTML property.