I want to open a new tab using javascript. But I should not lose my focus on the current tab

I want to open a new tab using javascript. But I should not lose my focus on the current tab.

So according to the gurus over at stackOverflow, the answer is a resounding … maybe.

Doing so would be a godsend to all sorts of cheezy popups and stuff, assuming the user was allowing popups through. But some browsers will let you do this, by calling (from the current window)

window.open(someUrl);
window.focus()

Not only won’t this work with every browser, it will break from one version of the same browser to the next. Just saying.

1 Like

Thank you but this is not working. I’m looking for a standard method that will work on every browser. Or an answer to whether it is possible.

And that was the answer. The best you’re going to get is “maybe it’ll work on the client’s particular browser, maybe it won’t. But if you are depending on it to work… don’t.”

There is no reliable way to open a new tab in the background from a web page. Back in the dark ages, twenty years ago, sure – happened all the time. And browsers were crashing because unwanted porn was being thrown up behind the current window. Modern browsers give the user a LOT more information and control.

So to answer your question, from a web page it isn’t possible.

Thank you for your answer. Very descriptive.