appendChild doesn't work correctly in IE

前端 未结 1 1511
死守一世寂寞
死守一世寂寞 2020-12-18 08:51

I am trying to create a simple Modal window, but IE isn\'t cooperating. When I call this function in IE, the content appears at the bottom of the page under all content and

相关标签:
1条回答
  • 2020-12-18 09:25

    This is common IE issue. It is irritating, but managable.

    If document.body.appendChild is executed within the body tag before the body is closed, IE6 will simply not load the page. 7 and 8 will wait until the page is loaded

    So, how to approach this issue?

    • wait until the body is loaded, using body.onload.
    • append the element to another element instead of the body tag.

    I recommend the second option. Appending elements to another target element will preserve the intended behavior and not change the way you add your elements to the site.

    0 讨论(0)
提交回复
热议问题