Home > Element Reference : Preference

Contents

### Preference

Mozilla 1.8

Declares a preference that may adjusted in a prefpane. This element should be placed inside a preferences element. Each preference element corresponds to a preference which is stored in the user's preferences file. You can connect a user interface element such as a checkbox to a preference element using the user interface element's preference attribute.

Attributes:

disabled | instantApply | inverted | name | onchange
readonly | tabindex | type

Properties and Methods:

disabled | hasUserValue | inverted | locked | name
preferences | readonly | reset | tabIndex | type
value

#### Attributes:

Inherited from XUL Element:

align
allowevents
allownegativeassertions
class
coalesceduplicatearcs
collapsed
container
containment
context
contextmenu
datasources
dir
empty
equalsize
flags
flex
height
hidden
id
insertafter
insertbefore
left
maxheight
maxwidth
menu
minheight
minwidth
mousethrough
observes
ordinal
orient
pack
persist
popup
position
preference-editable
ref
removeelement
sortDirection
sortResource
sortResource2
statustext
style
template
tooltip
tooltiptext
top
uri
wait-cursor
width

##### disabled

Type: boolean

If set to true, then changing the preference is disabled and the corresponding user interface element is disabled.

##### instantApply

Type: boolean

If true, the preference will be changed as soon as the user interface is modified.

##### inverted

Type: boolean

For boolean preferences, if this attribute is set to true, it indicates that the value of the preference is the reverse of the user interface element attached to it. For instance, checking the checkbox disables the preference instead of enabling it.

##### name

Type: string

The name of the preference to change. For example, the browser's home page is set with the preference 'browser.startup.homepage'.

##### onchange

Type: script code

The change event will be fired when the value of the preference is changed.

##### readonly

Type: boolean

If set to true, then the user cannot modify the value of the preference.

##### tabindex

Type: integer

The tab index of the corresponding user interface element.

##### type

Type: one of the values below

The preference type which should be one of the following values.

- bool: A boolean set to either true or false. Usually a checkbox would be connected to these preferences.
- int: An integer
- string: A string
- unichar: A Unicode string
- wstring: A localized string. In this situation the preference will save the path to a property file which contains the actual value of the preference.
- file: A file. The file path will be stored in the preferences.

#### Properties and Methods:

Inherited from XUL Element:

align
allowEvents
blur
boxObject
boxObject.element
boxObject.getLookAndFeelMetric
boxObject.height
boxObject.screenX
boxObject.screenY
boxObject.width
boxObject.x
boxObject.y
builder
className
click
collapsed
contextMenu
controllers
database
datasources
dir
doCommand
flex
focus
getElementsByAttribute
height
hidden
id
left
maxHeight
maxWidth
menu
minHeight
minWidth
observes
ordinal
orient
pack
persist
ref
resource
statusText
style
tooltip
tooltipText
top
width

Inherited from Element:

addEventListener
appendChild
attributes
childNodes
cloneNode
dispatchEvent
firstChild
getAttribute
getAttributeNS
getAttributeNode
getAttributeNodeNS
getElementsByTagName
getElementsByTagNameNS
hasAttribute
hasAttributeNS
hasAttributes
hasChildNodes
insertBefore
isSupported
lastChild
localName
namespaceURI
nextSibling
nodeName
nodeType
nodeValue
normalize
ownerDocument
parentNode
prefix
previousSibling
removeAttribute
removeAttributeNS
removeAttributeNode
removeChild
removeEventListener
replaceChild
setAttribute
setAttributeNS
setAttributeNode
setAttributeNodeNS
tagName

##### disabled

Type: boolean

Gets and sets the value of the disabled attribute.

##### hasUserValue ( )

Return Type: boolean

Returns true if the preference has been changed from its default value.

##### inverted

Type: boolean

Gets and sets the value of the inverted attribute.

##### locked

Type: boolean

If true, the preference has been locked and disabled in the system configuration, preventing the value from being changed. This property is read only.

##### name

Type: string

The name of the preference to change. For example, the browser's home page is set with the preference 'browser.startup.homepage'.

##### preferences

Type: element

Reference to the containing preferences element.

##### readonly

Type: boolean

If set to true, then the user cannot modify the value of the preference.

##### reset ( )

Return Type: boolean

Resets the preference to its default value.

##### tabIndex Mozilla 1.8

Type: integer

Get and sets the value of the tabindex attribute.

##### type

Type: string

Gets and sets the value of the type attribute.

##### value

Type: any

Holds the current value of the preference. Assigning a value to this property changes the preference. The correspond UI element is also updated.

Copyright (C) 1999 - 2004 XulPlanet.com