2014-09-22 52 views
1

我有一个愚蠢的问题,我不明白,googleing非常困难,因为我获得与window.open和脚本SRC 1000场琐碎的比赛= ..无法将<script src =“..”添加到使用window.open()创建的窗口中。document.write(9

我做这样的事情:我每次增加一行

myWin= open("", "displayWindow", "status=no,toolbar=no,menubar=yes"); 
myWin.document.open(); 
myWin.document.write("<html><head><title>Test-Window"); 
myWin.document.write('</title>'); 
myWin.document.write("<script src='my.js'/>"); 
myWin.document.write('</head><body><h1>Hello</h1></body></html>'); 
myWin.document.close(); 

myWin.document.write("<script src='my.js'/>"); 

窗口空。

我试过类似的东西:

var script = myWin.document.createElement('script'); ... 但效果相同。

我认为浏览器解释脚本结束标记并中断。但我能做什么呢?

非常感谢阅读,

亲切的问候

托马斯

+1

恕我直言,'document.createElement('script');'不应该抛出结束脚本标记错误,你有任何东西在控制台中触发?是my.js加载确定在硬编写的HTML页面? – Kaiido 2014-09-22 22:25:41

回答

0

要解决这个问题,你需要连接</script>结束标记。例如像这样:

myWin.document.write("<script src='my.js'></sc" + "ript>"); 
相关问题