Click here to Skip to main content
15,903,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to open window in a new tab and I need a focus to remain on the original page (not the new tab). This is browser setting as well.
Any idea how to do it?

JavaScript
window.open(url, '_blank');
window.focus();


is not the solution, this opens a tab in new window but the focus is moved to new tab.
Posted

1 solution

You need to use the return value of window.open to set the focus, like this:
JavaScript
var wnd = window.open(url, '_blank');
wnd.focus();

Good luck!
 
Share this answer
 
Comments
Petra Cerna 24-Oct-13 8:40am    
thank you but this gives a focus on the new tab as well

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900