【问题标题】:How to open links in new browser window using ie 11如何使用 ie 11 在新的浏览器窗口中打开链接
【发布时间】:2017-11-07 05:42:19
【问题描述】:

我可以在新浏览器(不是弹出窗口)窗口中点击打开链接吗?

我尝试过的事情:

<a href='http://osric.net/' onclick='return !window.open(this.href);'>osric.net web hosting</a>

一个函数onclick:

var windowObjectReference;
var strWindowFeatures = "menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes, toolbar=yes";

function openRequestedPopup() {
  windowObjectReference = window.open("http://www.cnn.com/", "CNN_WindowName", strWindowFeatures);
}

但有了这些,它只能在新标签中打开。

【问题讨论】:

  • 你如何区分“新浏览器窗口”和“弹出窗口”?

标签: javascript internet-explorer-11


【解决方案1】:

这适用于 IE 11:

<script>
function popupBrowser(url) {
  window.open(url, "WindowName", "config=menubar=no,location=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes,fullscreen=yes");
}
</script>

<a href="javascript:popupBrowser('http://www.cnn.com')">Open a new browser for IE11</a>

它只是通过使用windows.open()来模仿浏览器

JSFiddle demo

【讨论】:

    【解决方案2】:

    来了

    <a href="your_link" target="_blank">Visit</a>
    

    target="_blank" - 是关键

    将此用于新窗口

    <a href="print.html"  onclick="window.open('print.html', 'newwindow', 'width=300, height=250'); return false;"> Print</a>
    

    参考:Make a link open a new window (not tab)

    【讨论】:

    • 但是target='_blank' 不控制窗口是在选项卡中打开还是在新窗口中打开。
    猜你喜欢
    • 1970-01-01
    • 2019-04-07
    • 1970-01-01
    • 1970-01-01
    • 2012-01-26
    • 1970-01-01
    • 2015-01-11
    • 2017-11-22
    • 1970-01-01
    相关资源
    最近更新 更多