+3 votes
in Programming by (2.2k points)
How to open a new tab in background while focusing on old window, I want to open a new tab without changing focus on new tab .

Trying this but not working :

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

2 Answers

+1 vote
edited by

You can use this code :

<a href="https://asktofolks.com/" onclick="window.open('#','_blank');window.open(this.href,'_self');">Open a new tab in background</a>

Here when you will click on this link , this will open a new tab with current page and previous tab will open with new link (https://asktofolks.com/)  .


This will help you, in case any query pls let me know.

0 votes


just put a link in href attribute which url you want to open on click .

<a href="
https://google.com/" onclick="window.open(URL); self.focus();"><h1>Click</h1></a>

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated