Getting notified when the page DOM has loaded (but before [removed])

前端 未结 9 896
北恋
北恋 2020-12-09 06:37

I know there are some ways to get notified when the page body has loaded (before all the images and 3rd party resources load which fires the window.onload e

9条回答
  •  半阙折子戏
    2020-12-09 07:15

    YUI uses three tests to do this: for Firefox and recent WebKit there's a DOMContentLoaded event that is fired. For older Safari the document.readyState watched until it becomes "loaded" or "complete". For IE an HTML

    tag is created and the "doScroll()" method called which should error out if the DOM is not ready. The source for YAHOO.util.Event shows YUI-specific code. Search for "doScroll" in the Event.js.

提交回复
热议问题