Why does this [removed] iframe ads code completely break Internet Explorer?

前端 未结 6 1137
青春惊慌失措
青春惊慌失措 2021-02-13 14:19

So, I\'m trying to find an answer to why this problem is happening; I\'ve fixed the problem, but I want to know why it happened.

TL;DR

Google-provided conversi

6条回答
  •  南旧
    南旧 (楼主)
    2021-02-13 14:49

    There is 2 reasons why the first method should be slow.

    • document.write() blocks until it is actually performed
    • the window’s onload event doesn’t fire until all its iframes, and all the resources in these iframes, have fully loaded

    Your solution works because the iframe it creates does not request the remote url until after the onload event. Having a set timeout on the first code, you would also get the page to load, then the request to the remote url to fire.

    As to why the change of code broke the site, I can not seem to find any speed differences transferring between the two. Maybe it seemed faster because it was cached.

提交回复
热议问题