JavaScript.. Document.write.. weird document behaviour:'(

后端 未结 1 1792
[愿得一人]
[愿得一人] 2021-01-27 12:55

I\'m getting some very weird behaviour:( i hope someone can help

Using xmlhttp request im getting a javascript file with document. write and it looks something like this

相关标签:
1条回答
  • 2021-01-27 13:01

    That's what write() is doing, it writes inside a document. If the document is already closed(closed means completely loaded), write() will overwrite the document.

    Solution is simple: don't use write() when the document is already loaded. Use DOM-methods like appendChild() or insertBefore() to inject new nodes.

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