JS.Events.PageonLoadEvent.InitinJS
#pageStatus {
border:1px solid red;
padding: 2px;
color:red;
}
window.onload = init;
function init() {
var status = document.querySelector('#pageStatus');
status.innerHTML = 'LOADED!';
// start working!
// ....
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Example1 of the 'load' event</title>
</head>
<body>
<p>This page uses <code>window.onload = init;</code> in the JS code to execute the init function ONLY WHEN THE PAGE HAS BEEN LOADED!</p>
<p>This is important as very often we cannot do important things before the DOM is ready (all HTML elements have been created and can be manipulated from JavaScript).</p>
<p>PAGE STATUS: <span id="pageStatus">NOT LOADED YET</span></p>
</body>
</html>