The function code() is called window.onload. How to prove that the supernatural or paranormal doesn't exist? What's wrong with window.onload? - JavaScript - SitePoint Page Load Time in TypeScript - c-sharpcorner.com i am using angular 4 check box tree structure,i want to know The onload event can be used to check the visitor's browser type and browser version, and load the proper version of the web page based on the information. Forcing the opening to happen in a specific way, using. In the next example I will show you how to change the code to use TypeScript's Arrow Function. To register for the beforeunload event, you use the window.addEventListener () method: window .addEventListener ( 'beforeunload' , (event) => { // do something here }); Code language: JavaScript (javascript) Since the window is the global object, you can omit it like this: addEventListener ( 'beforeunload' , (event) => { // do something here }); Implement an onload Event in iframe in JavaScript | Delft Stack Follow these four easy steps and get a clear understanding of the window.onload method. Why are trials on "Law & Order" in the New York Supreme Court? But if you want to manipulate the DOM - you should definitely wait for it to properly load. Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this Suggestion An idea for TypeScript Milestone TypeScript 2.8.3 FileReader.onLoad/onLoadEnd event argument has no target.result If a visitor initiated navigation away from the page or tries to close the window, the beforeunload handler asks for additional confirmation. A window containing a DOM document; the document property points to the DOM document loaded in that window. Page: DOMContentLoaded, load, beforeunload, unload - JavaScript javascript - When to use "window.onload"? - Stack Overflow When the browser processes an HTML-document and comes across a