summaryrefslogtreecommitdiff
path: root/js/globals.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/globals.ts')
-rw-r--r--js/globals.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/js/globals.ts b/js/globals.ts
index 50f119971..b734b8da3 100644
--- a/js/globals.ts
+++ b/js/globals.ts
@@ -84,6 +84,7 @@ window.setTimeout = timers.setTimeout;
window.setInterval = timers.setInterval;
window.location = (undefined as unknown) as domTypes.Location;
window.onload = undefined as undefined | Function;
+window.onunload = undefined as undefined | Function;
// The following Crypto interface implementation is not up to par with the
// standard https://www.w3.org/TR/WebCryptoAPI/#crypto-interface as it does not
// yet incorporate the SubtleCrypto interface as its "subtle" property.
@@ -171,6 +172,16 @@ window.addEventListener(
}
}
);
+// Registers the handler for window.onunload function.
+window.addEventListener(
+ "unload",
+ (e: domTypes.Event): void => {
+ const onunload = window.onunload;
+ if (typeof onunload === "function") {
+ onunload(e);
+ }
+ }
+);
// below are interfaces that are available in TypeScript but
// have different signatures