JavaScript:生成新窗口(window.open)

JavaScript:生成新窗口(window.open),javascript,Javascript,我需要使用函数生成一个新窗口。我觉得一切都很好,但在我的任何浏览器中都不起作用。我不明白为什么它不起作用。请帮我把它弄好 <script> var newWin(); function openWin() { var features = "toolbar=yes,locationbar=1,directories=1,statusbar=1,menubar=1,scrollbar=1,resizable=yes,titlebar=1"; newWin = windo

我需要使用函数生成一个新窗口。我觉得一切都很好,但在我的任何浏览器中都不起作用。我不明白为什么它不起作用。请帮我把它弄好

<script>
var newWin();
function openWin() {
    var features = "toolbar=yes,locationbar=1,directories=1,statusbar=1,menubar=1,scrollbar=1,resizable=yes,titlebar=1";
    newWin = window.open("", "newWin", features);
    var topDoc = "<html><head><title>Dynamic window and document</title></head>";
    var endDoc = "</body></html>";

    newWin.document.write(topDoc, "<body>");
    newWin.document.write("<h1>Dynamic created Window and Document</h1>");
    newWin.document.write("<p><a href='javascript: opener.focus();'>Click here to put the other window on top</a></p>");

    newWin.document.write("<p><a href='javascript: AAAAAA'>Click here to close the other window</a></p>");
    newWin.document.write("<p><input type='button' onclick='self.print();' value='Send the content of this window to a printer'></p>");

    newWin.document.write("<p><input type='button' onclick='BBBBBB' value='Close this window'></p>");

    newWin.document.write(endDoc);

    newWin.document.close();
}

</script>

<p><a href="javascript: openWin();">Click to open a new window</a></p>

    <p><a href="#" onclick="newWin.focus();">Click to put the new window on top</a></p>

    <p><a href="#" onclick="newWin.close();">Click to close the new window</a></p>

var newWin();
函数openWin(){
var features=“toolbar=yes,locationbar=1,directories=1,statusbar=1,menubar=1,scrollbar=1,resizeable=yes,titlebar=1”;
newWin=window.open(“,”newWin“,features);
var topDoc=“动态窗口和文档”;
var endDoc=“”;
newWin.document.write(topDoc,“”);
newWin.document.write(“动态创建的窗口和文档”);
newWin.document.write(“”);
newWin.document.write(“”);
newWin.document.write(“”);
newWin.document.write(“”);
newWin.document.write(endDoc);
newWin.document.close();
}

多谢各位

<p><a href="javascript:{ openWin();}">Click to open a new window</a></p>

    <p><a href="#" onclick="javascript:{newWin.focus();}">Click to put the new window on top</a></p>

    <p><a href="#" onclick="javascript:{newWin.close();}">Click to close the new window</a></p>
var newWin

var newWin();