Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
加载使用document.write的外部javascript文件_Javascript_Document.write - Fatal编程技术网

加载使用document.write的外部javascript文件

加载使用document.write的外部javascript文件,javascript,document.write,Javascript,Document.write,我正在尝试使用以下代码添加外部javascript代码: function get_js(b){ var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = b; head.appendChild(script); } 此外部javascript代码使用do

我正在尝试使用以下代码添加外部javascript代码:

function get_js(b){
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = b;
head.appendChild(script);
    }
此外部javascript代码使用document.write-inside:

document.write('<script language="JavaScript">document.write(\'<div id="something" style="position: fixed; top: 0; bottom: 0; left: 0; right: 0;">&nbsp;<\/div>\');...
我认为document.write在JS代码中是个问题。有人能帮我吗

提前谢谢

///


好的,用POSTSCRIBE解决:

不要使用
document.write()
。如果在页面加载后调用
document.write()
,它将“重新打开”页面加载,并作为副作用清除屏幕上的所有内容


查看属性/方法,如
innerHTML
textContent
document.createElement()
appendChild()
,…

不要使用
document.write()
。如果在页面加载后调用
document.write()
,它将“重新打开”页面加载,并作为副作用清除屏幕上的所有内容


查看属性/方法,如
innerHTML
textContent
document.createElement()
appendChild()
,…

您应该避免使用文档。完全写入:是的,我知道,但这是第三方脚本。完全写入:是的,但这是第三方脚本。
ReferenceError: some_function is not defined