The example below correctly shows image sizes, because window.onload waits for all images: When a visitor leaves the page, the unload event triggers on window. The window.onload ensures all the elements are loaded and are available for document.getElementById ('my_iframe') to fetch them. Some examples: window.location.href returns the href (URL) of the current page. This is used with the window element to execute a script after the webpage has completely loaded. This event is not cancelable and does not bubble. To quickly begin app development, I use the "Create React . When the browser processes an HTML-document and comes across a