html onload code example
Example 1: JavaScript that executes after page load
document.addEventListener("DOMContentLoaded", function(){
});
window.addEventListener("load", function(){
});
Example 2: window.onload
window.onload = function() {
};
Example 3: on load javascript
window.onload = (event) => {
console.log('page is fully loaded');
};
Example 4: on load javascript
window.addEventListener('load', (event) => {
console.log('page is fully loaded');
});
Example 5: javascript onload
<body onload="myFunction()">