【发布时间】:2013-12-13 08:10:12
【问题描述】:
我有一个按钮单击,我在其中放置了一个 javascript 函数来打开一个新窗口,如果我再次单击该按钮,相同的窗口将再次刷新并指向它。在 firefox 和 chrome 中都可以使用。但在 IE 中不行。这是我尝试过的代码
<button onclick="popitup('http://www.google.com');">click</button>
var newwindow = null;
function popitup(url) {
if ((newwindow == null) || (newwindow.closed)) {
newwindow = window.open(url, 'Buy', 'width=950,height=650,scrollbars=yes,resizable=yes');
newwindow.focus();
} else {
newwindow.location.href = url;
newwindow.focus();
}
}
IE 一直返回 newwindow==null...这是问题...有什么解决办法吗?
【问题讨论】:
-
这到底是如何使用 C# 的?
-
默认按钮行为是
submit,所以尝试设置type='button' -
检查 IE 没有阻止弹出窗口,也可能重复 On IE9, Win 7 window.open() returns null instead of reference of the opened window
-
@Grundy ..IE 一直返回 newwindow==null ......这就是问题......任何解决方案?
-
@AnilkumarM 你检查 IE 不会阻止弹出窗口吗?你是通过链接去的吗?
标签: c# javascript jquery html