Detect failure to load contents of an iframe

前端 未结 6 1767
迷失自我
迷失自我 2020-12-01 06:59

I can detect when the content of an iframe has loaded using the load event. Unfortunately, for my purposes, there are two problems with this:

  • If there
6条回答
  •  情深已故
    2020-12-01 07:51

    Have a id for the top most (body) element in the page that is being loaded in your iframe.

    on the Load handler of your iframe, check to see if getElementById() returns a non null value. If it is, iframe has loaded successfully. else it has failed.

    in that case, put frame.src="about:blank". Make sure to remove the loadhandler before doing that.

提交回复
热议问题