HTML DOM
A close event is fired at a CloseWatcher object when a close request was received and only fired if the CloseWatcher.cancel_event event that preceded the close one was not canceled.
The close event handler is where the code to close the UI component should be called: this ensures that the component will be closed properly either from the platform-specific close signal or from a call to CloseWatcher.requestClose().
Syntax
Use the event name in EventTarget/addEventListener:
addEventListener("close", (event) => { })
Alternatively, assign to the event handler property of the interface:
onclose = (event) => { }
Event type
An Event.
Examples
Using the close event
Use the close to listen for close requests.
watcher.addEventListener("close", () => {
// Close your UI component
sidebar.hide();
});
Specifications
Browser compatibility
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
