js onload page code example
Example 1: window.onload
window.onload = function() {
// Some code
};
Example 2: reload page javascript
window.location.reload();
Example 3: javascript document load
window.addEventListener("load", function(event) {
console.log("Tutte le risorse hanno terminato il caricamento!");
});
Example 4: on load javascript
window.onload = (event) => {
console.log('page is fully loaded');
};
Example 5: javascript execute code on page load
<html>
<body onload="loaded();"></body>
<script>
function loaded() {
alert('Page is loaded');
}
</script>
</html>