How to fire “onload” event on document in IE

前端 未结 3 341
自闭症患者
自闭症患者 2021-01-18 06:16

I am currently developing Unit Tests for a Javascript method that detects the readiness of the document. This code is already at framework level, so please avoid mentions of

3条回答
  •  一整个雨季
    2021-01-18 06:49

    According to this page at MSDN, there's no onload event for document.

    You want either window.onload or document.body.onload. These are identical in IE: for historical reasons, actually sets window.onload, so MS decided to make document.body.onload an alias of window.onload.

    The problem with this is - as Eric mentioned in the comments - that there doesn't seem to be a way to manually fire window events, which means that there might not be a solution for Eric's problem.

提交回复
热议问题