【问题标题】:focus function not working in ie8焦点功能在ie8中不起作用
【发布时间】: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


【解决方案1】:

对我有用

function windowOpen(url) {
win = window.open(url, 'OpenPage', 'resizable=yes,width=900px,height=620px');
win.focus();

return false;

}

如果不是,请检查您当前的窗口名称是否与新窗口相同,如果是,请使用新窗口的另一个名称

【讨论】:

  • 你检查你的 IE 没有阻止弹出窗口吗?
  • @Grundy 对不起兄弟,但他没有回复你。这就是为什么我问同样的问题
【解决方案2】:

看看那个:

http://hardlikesoftware.com/projects/IE8FocusTest.html

希望对你有帮助..

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2020-07-22
  • 1970-01-01
  • 2012-10-28
  • 2014-02-03
  • 1970-01-01
  • 2013-10-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多