简体   繁体   English

在新标签中打开 url

[英]Opening url in new tab

I am trying to open a new tab with javascript.我正在尝试使用 javascript 打开一个新选项卡。
How to write it so that it would work in chrome, firefox and IE7?如何编写它才能在 chrome、firefox 和 IE7 中运行?
(the pages are on the same domain) (页面在同一个域上)

UPD: Let's presume that the user uses the default configuration of IE7... UPD:假设用户使用的是 IE7 的默认配置...

You cannot control how the browser will handle opening new popups / pages.您无法控制浏览器将如何处理打开新的弹出窗口/页面。 This is entirely handled by the browser.这完全由浏览器处理。 If the user has set their browser up to open new pages/popups in a new window, you cannot force your own page to open in a tab.如果用户已将浏览器设置为在新的 window 中打开新页面/弹出窗口,则不能强制在选项卡中打开自己的页面。

Plain HTML:普通 HTML:

<a href="newpage.html" target="_blank">click here</a>

Javascript: Javascript:

window.open("newpage.html", "_blank");

But keep in mind what psynnott said.但请记住 psynnott 所说的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM