+ 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.
2 Respostas
+ 3
window.addEventListener('DOMContentLoaded', () => {
console.log('page loaded');
});
+ 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.