如何将DOCTYPE添加到新的JavaScript生成窗口?

如何将DOCTYPE添加到新的JavaScript生成窗口?,javascript,html,doctype,window.open,Javascript,Html,Doctype,Window.open,我正在使用window.open用JavaScript生成一个新窗口,并在其中放入一些内容 如何声明?这是不可能的 window.open仅打开一个新的浏览器实例。在弹出窗口中,页面负责声明其doctype 编辑 事实上,我发现了这个,但是这个例子只有在您计划覆盖新打开的窗口的内容时才起作用 function openWin(){ var winTitle='blah'; var winBg='#FF0000'; var newWin=window.open('', ''

我正在使用
window.open
用JavaScript生成一个新窗口,并在其中放入一些内容

如何声明

这是不可能的

window.open仅打开一个新的浏览器实例。在弹出窗口中,页面负责声明其doctype

编辑

事实上,我发现了这个,但是这个例子只有在您计划覆盖新打开的窗口的内容时才起作用

function openWin(){
    var winTitle='blah';
    var winBg='#FF0000';
    var newWin=window.open('', '', 'height=130, width=160');
    newWin.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>'+winTitle+'</title></head>');
    newWin.document.write('<body bgColor="'+winBg+'"><img src="images/picture.jpg" border=0></body></html>');
    newWin.document.close();
} 
函数openWin(){ var winTitle='blah'; var winBg='#FF0000'; var newWin=window.open('','',高度=130,宽度=160'); newWin.document.write(“”+winTitle+“”); newWin.document.write(“”); newWin.document.close(); }
我不认为您可以使用
窗口。为此单独打开
,但似乎您可以通过多一点编码来完成

看看这个类似的问题。我认为你可以很容易地调整它来满足你的要求


document.doctype,但无法在DOM级别1中动态创建DocumentType对象;