Difference between DOMContentLoaded and load events

后端 未结 6 1960
执笔经年
执笔经年 2020-11-22 08:43

What is the difference between DOMContentLoaded and load events?

6条回答
  •  独厮守ぢ
    2020-11-22 09:16

    The DOMContentLoaded event will fire as soon as the DOM hierarchy has been fully constructed, the load event will do it when all the images and sub-frames have finished loading.

    DOMContentLoaded will work on most modern browsers, but not on IE including IE9 and above. There are some workarounds to mimic this event on older versions of IE, like the used on the jQuery library, they attach the IE specific onreadystatechange event.

提交回复
热议问题