HTMLDialogElement: closedBy 属性
HTMLDialogElement 接口的 closedBy 属性指示可用于关闭关联的 <dialog> 元素的*用户操作类型*。它设置或返回对话框的 closedby 属性值。
值
一个字符串;可能的值为
任意-
用户可以通过“浅层关闭”(light dismiss)操作、平台特定用户操作或开发人员指定的机制来关闭此对话框。
closerequest-
用户可以通过平台特定用户操作或开发人员指定的机制来关闭此对话框。
none-
此对话框只能通过开发人员指定的机制来关闭。
示例
closedBy 的基本用法
html
<dialog open closedby="any">
<h2>My dialog</h2>
<p>
Closable using the Esc key, or by clicking outside the dialog. "Light
dismiss" behavior.
</p>
</dialog>
js
const dialogElem = document.querySelector("dialog");
// Logs "any" to the console
console.log(dialogElem.closedBy);
规范
| 规范 |
|---|
| HTML # dom-dialog-closedby |
浏览器兼容性
加载中…