Dave
Dave

Reputation: 1593

window.open usage in google chrome causing strange 'tab vs new window' behaviour

We've recently put a change into our application that will stop forcing the opening of new windows when opening new pages. In most default setups this causes these pages to be opened as new tabs, but I realize this may be user dependent.

However, we've noticed some strange behaviour in chrome where the same call to:

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

will sometimes open in a tab and sometimes open in a new window. It appears to have something to do with a delay in the processing of the javascript, but I am not really sure.

The following JSFiddle has instructions for reproduction of the behaviour. Can anyone explain this behaviour or provide a means to use a single window.open call that will open consistently in the same way when a left click is used?

JSFiddle

Upvotes: 0

Views: 556

Answers (1)

Mendhak
Mendhak

Reputation: 8795

You can see a detailed response here; the gist is if it's a user initiated behavior, it will open in a new tab. If there is a delay of any sort, such as a timeout, then it will open in a new window. So your observations regarding the delay in processing are correct.

This may be a UI or workflow issue if your calls to window.open are sometimes delayed. Some of the other answers provided in the thread linked to may provide you with options.

Upvotes: 1

Related Questions