Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

dialog

window 元素调用对话框时应使用此元素。buttons 属性可以用于设置哪些按钮应该出现在对话框中。这些按钮将被放置在用户平台指定的位置。

更多有用信息可以查看 XUL tutorialDialogs and prompts (代码片段)。

属性
buttonaccesskeyaccept, buttonaccesskeycancel, buttonaccesskeydisclosure, buttonaccesskeyextra1, buttonaccesskeyextra2, buttonaccesskeyhelp, buttonalign, buttondir, buttondisabledaccept, buttonlabelaccept, buttonlabelcancel, buttonlabeldisclosure, buttonlabelextra1, buttonlabelextra2, buttonlabelhelp, buttonorient, buttonpack, buttons, defaultButton, ondialogaccept, ondialogcancel, ondialogdisclosure, ondialogextra1, ondialogextra2, ondialoghelp, title
特性
buttons, defaultButton
方法
acceptDialog, cancelDialog, centerWindowOnScreen, getButton, moveToAlertPosition

示例

Image:XUL_ref_dialog.png
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<dialog id="donothing" title="Dialog example"
   xmlns="https://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   buttons="accept,cancel"
   buttonlabelcancel="Cancel"
   buttonlabelaccept="Save"
   ondialogaccept="return doOK();"
   ondialogcancel="return doCancel();">
    
    <dialogheader title="Options" description="My preferences"/>
    <groupbox>
      <caption label="Colour"/>
      <radiogroup>
        <radio label="Red"/>
        <radio label="Green" selected="true"/>
        <radio label="Blue"/>
      </radiogroup>
      <label value="Nickname"/>
      <textbox />
   </groupbox>
</dialog>

属性

activetitlebarcolor
Type: color string
Specify background color of the window's titlebar when it is active (foreground). Moreover this hides separator between titlebar and window contents. This only affects Mac OS X.
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.
buttondisabledaccept
Type: boolean
If true, the accept button is disabled.
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
类型: 列表,下面的值用逗号分隔
需要显示在对话框上的按钮的一个列表,使用逗号分隔。将按钮放置在合适的位置,将根据用户平台自动执行基本的事件处理。在列表中可以使用以下值:
  • accept:“确定”按钮,按下按钮时将接受更改。此按钮为默认按钮。
  • cancel:“取消”按钮,将取消操作。
  • help:“帮助”按钮,在对话框显示一个“帮助”按钮。
  • disclosure:“更多信息”按钮,显示一个“more info”按钮。该按钮可能是一个按钮或一个三角形。
  • extra1:一个可选的额外的按钮。你可以通过buttonlabelextra1 属性设置它的label。
  • extra2:第二个可选的额外的按钮。你可以通过 buttonlabelextra2 属性设置它的label。
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.
inactivetitlebarcolor
Type: color string
Specify background color of the window's titlebar when it is inactive (background). Moreover this hides separator between titlebar and window contents. This affects only on Mac OS X.
ondialogaccept
Type: script code
The code in this attribute is called when the accept button is pressed, or when the acceptDialog method is called. If the handler returns true, the dialog will indeed go away, but if it returns false it will not.
ondialogcancel
Type: script code
The code in this attribute is called when the "cancel" button is pressed or when the cancelDialog method is called. If the routine returns true, the dialog will indeed go away, but if it returns false it will not.
ondialogdisclosure
Type: script code
The code in this attribute is called when the "disclosure" button is pressed.
ondialogextra1
Type: script code
The code in this attribute is called when the first extra button is pressed.
ondialogextra2
Type: script code
The code in this attribute is called when the second extra 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 in the title bar of the window.

特性

buttons
类型: 列表,下面的值用逗号分隔
需要显示在对话框上的按钮的一个列表,使用逗号分隔。将按钮放置在合适的位置,将根据用户平台自动执行基本的事件处理。在列表中可以使用以下值:
  • accept:“确定”按钮,按下按钮时将接受更改。此按钮为默认按钮。
  • cancel:“取消”按钮,将取消操作。
  • help:“帮助”按钮,在对话框显示一个“帮助”按钮。
  • disclosure:“更多信息”按钮,显示一个“more info”按钮。该按钮可能是一个按钮或一个三角形。
  • extra1:一个可选的额外的按钮。你可以通过buttonlabelextra1 属性设置它的label。
  • extra2:第二个可选的额外的按钮。你可以通过 buttonlabelextra2 属性设置它的label。

Note: If you don't want to display any buttons in the dialog box, set the value of this attribute to "," (a single comma).

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.

方法

Inherited Methods
addEventListener(), appendChild(), blur, click, cloneNode(), compareDocumentPosition, dispatchEvent(), doCommand, focus, getAttribute(), getAttributeNode(), getAttributeNodeNS(), getAttributeNS(), getBoundingClientRect(), getClientRects(), getElementsByAttribute, getElementsByAttributeNS, getElementsByClassName(), getElementsByTagName(), getElementsByTagNameNS(), getFeature(), getUserData, hasAttribute(), hasAttributeNS(), hasAttributes(), hasChildNodes(), insertBefore(), isDefaultNamespace(), isEqualNode, isSameNode, isSupported(), lookupNamespaceURI, lookupPrefix, normalize(), querySelector(), querySelectorAll(), removeAttribute(), removeAttributeNode(), removeAttributeNS(), removeChild(), removeEventListener(), replaceChild(), setAttribute(), setAttributeNode(), setAttributeNodeNS(), setAttributeNS(), setUserData

acceptDialog()
Return type: no return value
Accepts the dialog and closes it, similar to pressing the OK button.
cancelDialog()
Return type: no return value
Cancels the dialog and closes it, similar to pressing the Cancel button.
centerWindowOnScreen()
Return type: no return value
Centers the dialog on the screen.
getButton( type )
返回值类型: button元素
返回当前对话框中指定类型的button元素.
moveToAlertPosition()
Return type: no return value
Moves and resizes the dialog to a position and size suitable for an alert box.

相关

Elements
dialogheader

文档标签和贡献者

 最后编辑者: ziyunfei,