📜  除非显式打开,否则无法从异步加载的外部脚本写入文档 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:14.586000             🧑  作者: Mango

代码示例1
An asynchronously loaded script is likely going to run AFTER the document has been fully parsed and closed.
Thus, you can't use document.write() from such a script (well technically you can, but it won't do what you want).

You will need to replace any document.write() statements in that script with 
explicit DOM manipulations by creating the DOM elements and then inserting 
them into a particular parent with 
.appendChild() or 
.insertBefore() or setting 
.innerHTML or 
some mechanism for direct DOM manipulation like that.