-1

How do I stay in current tab when opening a new tab using javascript?

I am using this var myWindow = window.open(url, '_blank'); myWindow.focus();

But it is redirect to a new tab, I want to stay in current tab

Thanks in advance.

  • 1
    I think this is a duplicate of [this](http://stackoverflow.com/questions/10812628/open-a-new-tab-in-the-background). I don't think its legally possible to do so. [This](http://stackoverflow.com/questions/6897430/prevent-window-open-from-focusing) suggests a chrome extension API. – Mathias May 21 '14 at 10:18

1 Answers1

1

You can stay on same page by following ways :

window.location.replace(url);

or

window.location.href = url;
Pramod S. Nikam
  • 4,271
  • 4
  • 38
  • 62