HTMLDialogElement:close 事件

Baseline 2022

Newly available

Since March 2022, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

close 事件在对话框被关闭时,会在对应的 HTMLDialogElement 对象上被触发。

该事件不可取消,也不会冒泡。

语法

js
target.onclose = functionRef;

参数

functionRef 是一个函数名称或函数表达式。该函数接受一个 Event 对象作为它唯一的参数。

每次只能给一个对象添加 onclose 回调。你可能更喜欢使用 EventTarget.addEventListener() 方法,因为它更加灵活。

规范

Specification
HTML Standard
# event-close

浏览器兼容性

BCD tables only load in the browser

参见