Here is the circumstance: I have 2 pages:
Now in the html page, there will be internal Ja
It is also possible to use the DOMContentLoaded
event of the Window
interface.
addEventListener("DOMContentLoaded", function() {
// Your code goes here
});
The above code is actually adding the event listener to the window
object, though it's not qualified as window.addEventListener
because the window
object is also the global scope of JavaScript code in webpages.
DOMContentLoaded
happens before load
, when images and other parts of the webpage aren't still fully loaded. However, all the elements added to the DOM within the initial call stack are guaranteed to be already added to their parents prior to this event.