最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to open new tab instead of new window in Chrome in java scripts - Stack Overflow

programmeradmin2浏览0评论

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

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..

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

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..

Share Improve this question edited Jun 27, 2013 at 9:46 Pranav Singh 20.2k32 gold badges83 silver badges108 bronze badges asked Jun 27, 2013 at 9:34 ManojManoj 111 gold badge1 silver badge3 bronze badges 4
  • 1 Instead of "_new", you can use "_newtab" – knshn Commented Jun 27, 2013 at 9:38
  • I tried with that but still i am getting the new window.. – Manoj Commented Jun 27, 2013 at 9:42
  • 2 This depends on the browser settings, you can't probably change this: stackoverflow./a/4907854/1935077 – Petr R. Commented Jun 27, 2013 at 9:55
  • possible duplicate of Open url in new tab using javascript – sra Commented Dec 3, 2013 at 10:01
Add a ment  | 

4 Answers 4

Reset to default 0

It's work for me. Just

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

http://jsfiddle/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

Use _blank instead of "_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

Demo: http://jsfiddle/eH9tw/

it is depends on chrome and firefox tab setting.

For open new tab, you can write as below:

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

if new tab set as new window then it will open in new window, else it will open in new tab.

发布评论

评论列表(0)

  1. 暂无评论