'load event doesn't work with addEventListener but works with onload property

const body = document.querySelector("body");

body.addEventListener("load", () => {
  console.log("test");
});

body.onload = () => {
  console.log("test");
};

when i use only addEventListener i don't see the message in the console but if i use onload property or use onload attribute in the html it works



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source