script on load code example
Example 1: JavaScript that executes after page load
document.addEventListener("DOMContentLoaded", function(){
});
window.addEventListener("load", function(){
});
Example 2: window.onload execute after load page
window.onload = function() {
setTimeout(loadAfterTime, 5000)
};
function loadAfterTime(){
document.getElementById("menu").style.display="block";
}
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');
});