Dialog

This element should be used in place of the window element for dialog boxes. The buttons attribute may be used to set which buttons should appear in the dialog box. These buttons will be placed in the correct locations for the user's platform.

More information about dialog


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

buttonaccesskeyaccept

Type: string

The access key to use for the accept button.

buttonaccesskeycancel

Type: string

The access key to use for the cancel button.

buttonaccesskeydisclosure

Type: string

The access key to use for the disclosure button.

buttonaccesskeyextra1

Type: string

The access key to use for the first extra button.

buttonaccesskeyextra2

Type: string

The access key to use for the second extra button.

buttonaccesskeyhelp

Type: string

The access key to use for the help button.

buttonalign

Type: string

The value of the 'align' attribute for the box containing the buttons.

buttondir

Type: string

The value of the 'dir' attribute for the box containing the buttons.

buttonlabelaccept

Type: string

The label to appear on the accept button.

buttonlabelcancel

Type: string

The label to appear on the cancel button.

buttonlabeldisclosure

Type: string

The label to appear on the disclosure button.

buttonlabelextra1

Type: string

The label to appear on the first extra button.

buttonlabelextra2

Type: string

The label to appear on the second extra button.

buttonlabelhelp

Type: string

The label to appear on the help button.

buttonorient

Type: string

The value of the 'orient' attribute for the box containing the buttons.

buttonpack

Type: string

The value of the 'pack' attribute for the box containing the buttons.

buttons

Type: comma-separated list of the values below

A comma-separated list of buttons to appear on the dialog box. The buttons will be placed in suitable locations for the user's platform and basic event handling will be performed automatically. The following values can be used in the list:

defaultButton

Type: string

Normally this attribute should not be set, but if it is, it specifies the default button in the dialog. Typically, this means that the button will be activated when the Enter key is pressed. This should be set to one of the same values as those for the buttons attribute.

ondialogaccept

Type: script code

The code in this attribute is called when the OK button is pressed, or when the acceptDialog function is called.

ondialogcancel

Type: script code

The code in this attribute is called when the Cancel button is pressed, or when the cancelDialog function is called.

ondialogdisclosure

Type: script code

The code in this attribute is called when the disclosure button is pressed.

ondialoghelp

Type: script code

The code in this attribute is called when the Help button is pressed.

title

Type: string

The text to appear on the title bar of the dialog box.


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

acceptDialog ( )

Return Type: no return value

Accepts the dialog and closes it, similar to pressing the OK button.

buttons

Type: comma-separated list of the values below

A comma-separated list of buttons to appear on the dialog box. The buttons will be placed in suitable locations for the user's platform and basic event handling will be performed automatically. The following values can be used in the list:

cancelDialog ( )

Return Type: no return value

Cancels the dialog and closes it, similar to pressing the Cancel button.

centerWindowOnScreen

Type: no return value

Centers the dialog on the screen.

defaultButton

Type: string

Normally this attribute should not be set, but if it is, it specifies the default button in the dialog. Typically, this means that the button will be activated when the Enter key is pressed. This should be set to one of the same values as those for the buttons attribute.

getButton ( type )

Return Type: button element

Returns the button element in the dialog corresponding to the given type.

moveToAlertPosition

Type: no return value

Moves and resizes the dialog to a position and size suitable for an alert box.

Add a note User Contributed Notes
March 15, 2005, 11:15 pm djoham at yahoo dot com
If you need access to one of the dialog buttons, you can get at them with the following code:

document.documentElement.getButton("<button>");

for example:
document.documentElement.getButton("accept");

This is useful if you want to do weird things like add images to the standard dialog buttons or enable/disable them via javascript for whatever reason. You also can get access to their parent container (an hbox) if you want to fiddle with their placement on the dialog.
January 20, 2005, 5:37 am asqueella at gmail dot com
There are a few attributes of <dialog> element not listed here:
buttonlabelaccept, buttonlabelcancel, buttonlabelhelp, buttonlabeldisclosure, buttonlabelextra1, buttonlabelextra2 and buttonaccesskey{accept,cancel,help,disclosure,extra1,extra2} which allow you to override default labels and accesskeys without having to use <button dlgtype="..."/> tip from previous comment. You can read more about it in MozillaZine knowledge base.
February 1, 2004, 10:09 am enndeakin at sympatico dot ca
To use a custom button in place of one of the default dialog buttons, create a button with a dlgtype attribute and place it in the dialog. This is how you would replace the label. For example:


<button dlgtype="accept" label="Yes"/>


This code will replace the standard accept button with your own button. You can also use other things that are non-buttons which is mostly useful to implement the disclosure button as a little triangle.

Copyright © 1999 - 2005 XULPlanet.com