0
我需要使用函數生成一個新窗口。一切看起來都很好,但它在我的任何瀏覽器中都不起作用。我無法弄清楚爲什麼它不起作用。請幫助我使它工作。JavaScript:生成新窗口(window.open)
<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>
謝謝
@Artem它爲我工作現在。就是它工作ü – PSR 2013-03-17 01:22:08
是的,非常感謝@PSR! – Art 2013-03-17 01:32:37