【问题标题】:IE on click of a link opens pop up again and again instead of showing in the same screen单击链接时 IE 会一次又一次地弹出而不是显示在同一屏幕上
【发布时间】:2014-07-04 06:11:59
【问题描述】:

当我单击我的应用程序标题中的链接时,它应该会打开一个弹出屏幕,但是当我从另一个页面单击相同的链接时,它会在另一个弹出窗口中打开,即使我没有关闭之前的那个。此问题仅在 IE 中普遍存在,在其他浏览器中不存在。

function popUpForInvoice(url) 
{
   var csrfName = document.getElementById("csrf").getAttribute("name");
   var csrfToken = document.getElementById("csrf").value;
   var newUrl = "/ecommerce/mitac/" + url + "&"+ csrfName + "=" + csrfToken;
   var left = (screen.width/2)-(550/2);
   var top = (screen.height/2)-(550/2);
   var  ua = window.navigator.userAgent;
   var msie = ua.indexOf("MSIE");
   if (msie > 0)      
       window.open(newUrl,'_blank','toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=no,width=540,height=600,left ='+left+',top ='+top+'');
else                 
       window.open(newUrl,'about:blank','toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=no,width=540,height=600,left ='+left+',top ='+top+'');
}

【问题讨论】:

    标签: javascript internet-explorer window.open


    【解决方案1】:
    1. _blank 作为目标被设计为每次打开一个新窗口
    2. about:blank 不是一个有效的目标 - 使用类似 mywindow 的东西来重用
    3. 不需要代理测试,顺便说一句,在 IE11 中无论如何都会失败。
    4. 您的某些参数不是必需的,并且参数中不允许有空格

    这应该可以工作

    删除

    var  ua = window.navigator.userAgent;
     var msie = ua.indexOf("MSIE");
     if (msie > 0)      
           window.open(newUrl,'_blank','toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=no,width=540,height=600,left ='+left+',top ='+top+'');
    else                 
    

    只有拥有

    window.open(newUrl,'mywindow',
     'scrollbars,resizable=no,width=540,height=600,left='+left+',top='+top);
    

    请注意,您可能需要聚焦窗口,否则在第二次和后续打开时它会停留在下方

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-27
      • 2015-06-04
      • 2017-02-16
      • 2021-03-30
      • 1970-01-01
      • 1970-01-01
      • 2013-09-18
      • 2012-09-02
      相关资源
      最近更新 更多