1window.addEventListener('load', (event) => {
2 console.log('page is fully loaded');
3});
1// Log a message when the page is fully loaded:
2
3window.addEventListener('load', (event) => {
4 console.log('page is fully loaded');
5});
1// The same, but using the onload event handler property:
2
3window.onload = (event) => {
4 console.log('page is fully loaded');
5};
6
1const log = document.querySelector('.event-log-contents');
2const reload = document.querySelector('#reload');
3
4reload.addEventListener('click', () => {
5 log.textContent ='';
6 window.setTimeout(() => {
7 window.location.reload(true);
8 }, 200);
9});
10
11window.addEventListener('load', (event) => {
12 log.textContent = log.textContent + 'load\n';
13});
14
15document.addEventListener('readystatechange', (event) => {
16 log.textContent = log.textContent + `readystate: ${document.readyState}\n`;
17});
18
19document.addEventListener('DOMContentLoaded', (event) => {
20 log.textContent = log.textContent + `DOMContentLoaded\n`;
21});
22
23