Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
135
rated 0 times [  139] [ 4]  / answers: 1 / hits: 91601  / 13 Years ago, fri, october 28, 2011, 12:00:00

How can I open a new tab using javascript without switching to the new tab?

For example, when a user clicks on a link a new tab is to be opened, but the user should stay on the current tab.


More From » html

 Answers
46

The web browser automatically focuses on the new tab, but you can call the focus back:



function openWindow( url )
{
window.open(url, '_blank');
window.focus();
}

<a href=http://www.example.com/ onclick=javascript:openWindow(this.href);return false;>Click Me</a>

[#89408] Wednesday, October 26, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
benitoh

Total Points: 150
Total Questions: 113
Total Answers: 104

Location: India
Member since Wed, Aug 26, 2020
4 Years ago
benitoh questions
Sun, Mar 21, 21, 00:00, 3 Years ago
Mon, May 13, 19, 00:00, 5 Years ago
;