var windowUrl = "";
var windowName = "mywin";
var w = window.open(windowUrl, windowName, windowSize);
w.document.write(html);
w.document.close();
这与onclick有关。如果窗口存在,我不想写或关闭甚至打开(也许重新聚焦)。我找到了一些例子,但它们似乎并没有“起作用”(或者我认为我需要它。)
答案 0 :(得分:5)
尝试以下方法:
<script type="text/javascript">
function loadUniquePage(page)
{
if (opener && !opener.closed) {
opener.focus();
} else {
var myWin = window.open(page,'','width=800,height=600');
opener = myWin;
}
}
</script>
还要看一下这个问题 - JavaScript window.open only if the window does not already exist
另请查看@Aram Kocharyan提供的链接:
https://developer.mozilla.org/en/DOM/window.closed