HTMLDialogElement:close 事件

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2022.

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

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

语法

js
target.onclose = functionRef;

参数

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

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

规范

Specification
HTML
# event-close

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
close event

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见