Javascript to open URL within a new Tab (instead of a window)(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


- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Flexslider 箭头未正确显示 2022-01-01