如何使用HTML/JS在chrome中打开一个新标签?

时间:2021-09-14 07:29:07

I tried this code

我试着这段代码

window.open('page2.html','_newtab');

window.open(“page2.html”、“_newtab”);

And all it opened was a new window. How do I open a new tab?

它打开的只是一扇新的窗户。如何打开新标签?

3 个解决方案

#1


10  

This is a browser setting and not something you can control with code. In my browser, your "window.open" will open a new tab, because that's what I have mine set up to do. In others' browsers, it might open a new window.

这是一个浏览器设置,不是你可以用代码控制的。在我的浏览器里,你的“窗口”。打开“将打开一个新的标签,因为这是我的设置要做的。在其他浏览器中,它可能会打开一个新窗口。

#2


0  

I don't think you can, from HTML / Javascript, indicate that a page should be opened in a new tab.

我认为,从HTML / Javascript来看,不可能在新选项卡中打开页面。

(In fact, your page might be opened to a new window, or to a new tab, depending on the configuration of the browser)

(事实上,根据浏览器的配置,您的页面可能会被打开到一个新的窗口或一个新的选项卡)

#3


0  

You can do this easily. See the answer here.

这很容易做到。在这里看到的答案。

#1


10  

This is a browser setting and not something you can control with code. In my browser, your "window.open" will open a new tab, because that's what I have mine set up to do. In others' browsers, it might open a new window.

这是一个浏览器设置,不是你可以用代码控制的。在我的浏览器里,你的“窗口”。打开“将打开一个新的标签,因为这是我的设置要做的。在其他浏览器中,它可能会打开一个新窗口。

#2


0  

I don't think you can, from HTML / Javascript, indicate that a page should be opened in a new tab.

我认为,从HTML / Javascript来看,不可能在新选项卡中打开页面。

(In fact, your page might be opened to a new window, or to a new tab, depending on the configuration of the browser)

(事实上,根据浏览器的配置,您的页面可能会被打开到一个新的窗口或一个新的选项卡)

#3


0  

You can do this easily. See the answer here.

这很容易做到。在这里看到的答案。