+ 1

¿Do you know how to onload a script using the onload method?

This is very helpful when you want to execute an script after the whole page has loaded. Note: my English is not very good, sorry.

6th Nov 2019, 1:26 AM
Fernando Orozco
Fernando Orozco - avatar
2 Réponses
+ 3
window.addEventListener('DOMContentLoaded', () => { console.log('page loaded'); });
6th Nov 2019, 11:31 AM
Labham Jain
Labham Jain - avatar
+ 1
Classic JS way: window.onload = function() { myFunction(); } function myFunction() { alert("Hey! I'm myFunction. I'm invoked by load event handler"); } Others can give you example of it with modern JS later on.
6th Nov 2019, 4:07 AM
Ipang