-1

Is there any difference between element.addEventListener('load', func) and element.onload=func?

Sin
  • 1,040
  • 1
  • 8
  • 20

1 Answers1

-1

The DOM "load" event still does only work very limited. That means it'll only fire for the window object, images and <script> elements for instance. The same goes for the direct onload assignment. There is no technical difference between those two. Probably .onload = has a better cross-browser availability.

However, you cannot assign a load event to a <div> or <span> element or whatnot.

the system
  • 9,244
  • 40
  • 46
Amrendra
  • 2,019
  • 2
  • 18
  • 36