gpt4 book ai didi

javascript - Mozilla XUL - 对话框按钮的 ID

转载 作者:行者123 更新时间:2023-11-29 19:37:07 25 4
gpt4 key购买 nike

我在想是否有办法将 ID 属性添加到对话框中的“接受”和“取消”按钮?

<dialog id="myDialog" title="My Dialog"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="window.sizeToContent();"
buttons="accept,cancel"
buttonlabelaccept="Set Favourite"
buttonaccesskeyaccept="S"
ondialogaccept="return doSave();"
buttonlabelcancel="Cancel"
buttonaccesskeycancel="n"
ondialogcancel="return doCancel();">

我知道我可以像这样添加按钮:

<button
id="identifier"
class="dialog"
label="OK"
image="images/image.jpg"
disabled="true"
accesskey="t"/>

但这可以在对话上下文中完成吗?

最佳答案

它可以在对话上下文中完成。但您发布的代码可能无法按预期工作,具体取决于您期望实现的目标。

您发布的按钮将不会用作接受按钮,除非它具有特殊属性 dlgtype="accept"。引用 this article谈论创建自定义对话框按钮:

If you are not satisfied with the layout of predefined buttons in dialog, you can put explicit button elements in your XUL file and add a dlgtype attribute to them. Valid values for dlgtype are the six button types listed above.

<button
dlgtype="accept"
class="dialog"
label="OK"
image="images/image.jpg"
disabled="true"
accesskey="t"/>

此方法使您能够选择接受按钮的位置、样式等。


如果目标是在代码中的某处获取接受按钮并操作其属性,则只需使用 document.documentElement.getButton("accept")。引用同一篇文章:

// Disable the OK and Cancel btns
document.documentElement.getButton("accept").disabled = true;
document.documentElement.getButton("cancel").disabled = true;

如果您想要不同的东西,请告诉我。

关于javascript - Mozilla XUL - 对话框按钮的 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24833013/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com