HTMLElement.onWindowMigrated method
HTMLElement › onWindowMigrated
Official
Adds an event listener to the element when it is migrated to another window.Signature:
onWindowMigrated(this: HTMLElement, listener: (win: Window) => unknown): () => voidParameters:
| Parameter | Type | Description |
|---|---|---|
| this | HTMLElement | |
| listener | (win: Window) => unknown | the callback to call when this node has been migrated to another window. |
Returns: () => void — destroy - a function to remove the event handler to avoid memory leaks.
Example:
document.body.onWindowMigrated((win) => { console.log('window migrated');});