我打开使用JS的新页面,并写入它的HTML代码,但是当我尝试使用document.write()
函数写入新页面内的JS时,它不起作用。显然,主JS在看到</script>
后立即关闭,这是用于将要打开的新页面的JS。JavaScript如何创建包含更多JavaScript的新页面?
有没有在这附近?
var opened = window.open("");
opened.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
opened.document.write("<html lang=\"en-US\" xml:lang=\"en-US\" xmlns=\"http://www.w3.org/1999/xhtml\">");
opened.document.write("<head><title>Print Copy</title></head>");
opened.document.write("<body>");
opened.document.write("<script type=\"text/javascript\">");
opened.document.write("</script>");
opened.document.write("<p>test</p></body></html>");
你见过这个呢:http://stackoverflow.com/questions/1985385/script-inside-javascript-code-document-write?将脚本移动到外部文件可能会导致IE挂起* document.write *?好奇... – 2010-01-05 09:35:09