Ishan Jain
Ishan Jain

Reputation: 8161

Open new tab without leave focus on previous tab

i want to open a new tab on click but i want to previous tab always active, child tab not active by default

My code is-

             <a onclick="window.open(URL); self.focus();>Click</a>

Upvotes: 1

Views: 8343

Answers (2)

Ayyash
Ayyash

Reputation: 4399

You can write code onload of the new window that gives focus back to the opener:

window.opener.focus();

notice that window.open opens a new window not a new tab, target=_blank opens a new tab (optionally according to browser settings)

Upvotes: 0

scottlimmer
scottlimmer

Reputation: 2268

This behaviour is up to the browser and can't be controlled by Javascript.

Upvotes: 4

Related Questions