简体   繁体   English

如何在Java脚本中在Chrome中打开新标签而不是新窗口

[英]How to open new tab instead of new window in Chrome in java scripts

Using this below code I am able to open new tab along with the URL..in Firefox..but same code when I am trying to open in Chrome its opening new window which I don't want new window ..I want new tab in case of chrome使用下面的代码,我可以在 Firefox 中打开带有 URL 的新标签......如果是铬

Here is my code:这是我的代码:

> window.open(this.getJavaURL +
                        ((this.returnPage != null) ?
                        ('&returnPage=' + this.returnPage) : '') +
                        ((this.locale != null) ?
                        ('&locale=' + this.locale) : '') +
                        ((this.brand != null) ?
                     ('&brand=' + this.brand) : ''),'_new');

Can you please help me..你能帮我么..

Use _blank instead of "_new"使用_blank而不是“_new”

It will instruct the browser to create a new browser tab or window when the user clicks on the link.当用户单击链接时,它将指示浏览器创建一个新的浏览器选项卡或窗口。

As per reference : _new is not valid根据参考_new无效

Demo: http://jsfiddle.net/eH9tw/演示: http : //jsfiddle.net/eH9tw/

It's work for me.这对我有用。 Just只是

    window.open('http://google.com');   

http://jsfiddle.net/HFeQj/ http://jsfiddle.net/HFeQj/

Wether a new window or new tab is openend is based upon your browser configuration, within the browser you can set to always open popups in new tabs.新窗口或新标签是否打开取决于您的浏览器配置,在浏览器中,您可以设置为始终在新标签中打开弹出窗口。

_new might break it and always open a window, _blank is the way to go like Satpal says _new 可能会打破它并总是打开一个窗口,_blank 是像 Satpal 所说的那样

it is depends on chrome and firefox tab setting.这取决于chromefirefox选项卡设置。

For open new tab, you can write as below:对于打开新标签,你可以写如下:

 window.open('http://google.com');

if new tab set as new window then it will open in new window, else it will open in new tab.如果新标签设置为新窗口,那么它将在新窗口中打开,否则它将在新标签中打开。

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

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