Why is my onload event in Javascript not working

This code is not displaying anything on the p tag as it suppose to do. <!DOCTYPE html> <html> <body id="myBody"> <h1>HTML DOM Events</h1> <h2>The onload Event</h2> <p id="demo"></p> <script> document.getElementById("myBody").addEventListener("load", checkCookies); function checkCookies() { var text = "This page "; if (navigator.cookieEnabled == true) { text = "Cookies are enabled."; } else { text =… Read More Why is my onload event in Javascript not working

Document 'load' event callbacks not called; how did I mess this up?

In this HTML document, in Chrome, none of my load event callbacks are called: <!DOCTYPE html> <html> <head> <title>test</title> <script> console.log(‘just checking’); function someFunction () { console.log(‘test 3’); } document.addEventListener(‘load’, () => console.log(‘test 1’)); document.addEventListener(‘load’, function () { console.log(‘test 2’); }); document.addEventListener(‘load’, someFunction); </script> </head> <body> </body> </html> However, I can see that they are… Read More Document 'load' event callbacks not called; how did I mess this up?