1.

What is the difference between and ?

Answer»

It is true that both the <window.onload> and <onDocumentReady> FUNCTIONS perform tasks when the page has been LOADED in the BROWSER, however, the execution of the two functions differs slightly.

  • Window.onload: This event is triggered when a web page has fully loaded. In other words, it waits for the DOM and all the associated resources to load, and then executes code. DOM contains all HTML tags, like ANCHOR tag, h1 tag, p tag, etc.
  • onDocumentReady: The "onDocumentReady" method, on the other hand, executes the code when the DOM has been loaded. It typically waits for HTML tags, anchor tags, etc., but not for IMAGES, videos, or other contents.


Discussion

No Comment Found