Is window.document ever null or undefined?

后端 未结 4 793
梦谈多话
梦谈多话 2020-12-06 02:56

I\'ve been doing some research on the window.document object in order to make sure one of my JavaScript solutions is reliable. Is there ever a case when the window.document

4条回答
  •  一向
    一向 (楼主)
    2020-12-06 03:21

    Ignoring the fact that Javascript runs other places besides web browsers/user-agents, your pageLoaded test may fail on iframes (untested, but I know they get weird).

    There may also be some question about what does "page loaded" mean. Are you trying to see if the DOM has been rendered and the elements are ready to be manipulated? Or are you checking to see if the page load is indeed complete, which includes having all of the other elements, such as graphics, loaded as well.

    This discussion may be useful: How to check if DOM is ready without a framework?

提交回复
热议问题