Javascript 在新选项卡(而不是窗口)中打开 URL

Javascript to open URL within a new Tab (instead of a window)(Javascript 在新选项卡(而不是窗口)中打开 URL)

本文介绍了Javascript 在新选项卡(而不是窗口)中打开 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.这里有一些条目需要解决方案来做与此相反的事情,而其他一些则模糊相关.在其中一个中,发帖人询问如何在 Mozilla Firefox 上执行此操作.实际上,当 window.open() 被调用时,firefox 会总是在新标签页中打开 URL,除非你在其参数中设置了窗口的大小.

Hey guys. There are a few entries here requiring solutions to do the opposite of this, and others vaguely related. In one of them, the poster asked how to do this on Mozilla Firefox. Actually though, firefox will always open the URL in a new tab when window.open() is called, unless you set the window's size within its parameters.

所以 Mozilla 和 Chrome 默认做我想做的事.问题是:如何让 Internet Explorer 在新选项卡中打开我想要的 URL,而不是在新窗口中打开?

So Mozilla and Chrome do what I want by default. The question is: how do I get Internet Explorer to open the URL I want within a new tab, as opposed to doing it in a new window?

提前致谢.

推荐答案

显而易见的答案是用target="_blank"打开链接.正如你所说,Firefox 和 Chrome 会打开一个新标签页.

The obvious answer is to open the link with target="_blank". As you said, Firefox and Chrome will open a new tab.

关于 IE - 行为取决于浏览器首选项.默认情况下(显然在 IE7+ 中)我相信该行为被定义为打开新选项卡.如果用户决定该行为应该是一个新窗口,那么您能做的就只有这么多了.

Regarding IE - the behavior is up to browser preferences. By default (in IE7+ obviously) I believe the behavior is defined as open new tab. If the user decided the behavior should be a new window, there's only so much you can do about it.

这篇关于Javascript 在新选项卡(而不是窗口)中打开 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Javascript 在新选项卡(而不是窗口)中打开 URL

基础教程推荐