Firefox DOMContentLoaded event

The DOMContentLoaded event in Firefox and Mozilla browsers is used to perform actions when the DOM has finished loading and is ready.

This event in Firefox and in the entire range of Mozilla-based browsers is very remarkable because it is used to execute instructions when the browser is ready to perform actions on the DOM, the object structure of the page.

This article itself is a bit simple and doesn’t say much, but we are going to use this event in some scripts of the . For now, these notes will serve to know the event and how to use it and later we will give keys on its use and practical examples.

This event is similar, but with one important difference, to another one we’ve seen for Internet Explorer, which allows you to perform actions when the loading state of a page element changes. Read the article.

Luckily Firefox offers us an improvement in terms of the usefulness of this event, since without having to do anything else, it allows us to do things with the DOM when it is already loaded and ready to work with it. The DOMContentLoaded event is executed when the DOM content has been fully loaded and is therefore ready to receive Javascript instructions.

if (document.addEventListener) {
document.addEventListener(“DOMContentLoaded”, initialize, false);
}

This simple code will execute the initialize() function, when the DOM has been loaded and is ready. Read the call to the document.addEventListener() method and you’ll see that the name of the initialize function is indicated as a parameter, just like the type of event we’re working with: DOMContentLoaded.

Loading Facebook Comments ...
Loading Disqus Comments ...