Property

Declares a JavaScript property that is added to the element's object. The property element may have a getter child element and a setter child element to get and set the value of the property respectively.

For example, you might want to add a selected property to a drop-down box. Properties make it convenient if an object is going to be used a lot with scripts.

The property element may have content which is code that determines the initial value of the property.

More information about property

Attributes:

id name onget onset readonly

Attributes:

id

Type: element id, must be unique in the window

A unique identifier so that you can identify the property with. You can use this as a parameter to getElementById and other DOM functions and to reference the element in style sheets.

name

The name of the property, which is the name that can be used via a script. For example, if a property has the name color, it can be accessed with object.color, where object is a reference to the object.

onget

The code contained in the onget attribute is called when an attempt is made to retrieve the value of the property. You may use this attribute when only a simple script is required. For longer scripts, you should use the getter element, which functions similarly. The onget code should return the value of the property.

onset

The code contained in the onset attribute is called when an attempt is made to modify the value of the property. You may use this attribute when only a simple script is required. For longer scripts, you should use the setter element, which functions similarly. Within the code of the onset attribute, the variable val is set to the value that the property should be changed to.

readonly

If set to true, the value of the property cannot be changed. If set to false, the property may be changed.


Copyright (C) 1999 - 2004 XulPlanet.com