on load js code example
Example 1: window.onload
window.onload = function() {
// Some code
};
Example 2: on load javascript
window.onload = (event) => {
console.log('page is fully loaded');
};
Example 3: on load javascript
window.addEventListener('load', (event) => {
console.log('page is fully loaded');
});
Example 4: run on load js
function codeAddress() {
alert('ok');
}
window.onload = codeAddress;
Example 5: javascript onload
<body onload="myFunction()">
Example 6: on dom load js
window.addEventListener('DOMContentLoaded', (event) => {
console.log('DOM fully loaded and parsed');
});