javascript 如何在Java脚本中在Chrome中打开新标签而不是新窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17339632/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to open new tab instead of new window in Chrome in java scripts
提问by Manoj
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..
你能帮我么..
回答by Satpal
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: _newis not valid
根据参考:_new无效
回答by jQuery00
It's work for me. Just
这对我有用。只是
window.open('http://google.com');
回答by Samantha Adrichem
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 所说的那样
回答by Amit
it is depends on chrome
and firefox
tab setting.
这取决于chrome
和firefox
选项卡设置。
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.
如果新标签设置为新窗口,那么它将在新窗口中打开,否则它将在新标签中打开。