Asked 3 years ago
24 Sep 2021
Views 4425
Roscoe

Roscoe posted

Javascript - Uncaught TypeError: window.load is not a function


window.load(function(){
  /// herr my code which load after dom ready or window load complete
})


I want to run some javascript code after the browser load all element of the website. but I got following error :
Uncaught TypeError: window.load is not a function
Rasi

Rasi
answered Sep 24 '21 00:00

you cant use window.load(function(){}) because there is no window.load function is there in javascript but use following code for window.onload event

window.onload = (event) => {
//put here code  
} 


when the window completes the load then window.onload event trigger.


ravi

ravi
answered Sep 24 '21 00:00

Ha ha, there is no window.load function

you mean window.onload , right ?
you can assign any function to window.onload like this and it will run after window load.

window.onload = function() {
 alert("Hello world");
};
Post Answer