DOM Window: load event
The window's load event fires when the whole page has loaded, including images, style sheets and iframes.
Description
The load event fires on the window when the whole page has loaded, including all dependent resources such as images, style sheets and iframes. It comes after DOMContentLoaded. Use it when your code needs the final layout or image sizes; for most set-up code, DOMContentLoaded runs sooner. Individual images and scripts also fire their own load events.
If you add a load listener after the page has already finished loading, it never runs, so check document.readyState === 'complete' first in code that might load late. Slow images or third-party resources delay this event, so avoid waiting for it for anything users need straight away.
Listeners for window events are added with window.addEventListener(). The older way, assigning a function to a property such as window.onresize, only allows one handler, so a second assignment replaces the first.
Syntax
window.addEventListener('load', handler)Example
Browser Support
The following information will show you the current browser support for the Window: load event event. Hover over a browser icon to see the version that first introduced support for this event.
Desktop





Tablets & Mobile





