Is there any difference between element.addEventListener('load', func)
and element.onload=func
?
Asked
Active
Viewed 249 times
-1

Sin
- 1,040
- 1
- 8
- 20
1 Answers
-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