user image

Joseph Morgan
Published in : 2021-12-22

How to open URL in new tab & focus on it in Javascript?

Javascript

How can I open URL in new tab & focus on it in Javascript? the url is in the new website, I am using window.open but it's not working as I am expecting 

window.open('//localhost:3000/', '_blank');

Thanks in advanced

 

Comments

Mohamed Atef Date : 2021-12-22

Best answers

51

Best answers

51

You can try 

 window.open('/company/locations', '_blank').focus();

this should be working as you need, Good luck

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

How select specific tag in jQuery using if else statement?
Publish date: 2022-02-27 | Comments: 1

Tag: Javascript

Method refactoring to avoid to many npe checks
Publish date: 2022-03-05 | Comments: 0

Tag: Javascript

Check if div have touch another div
Publish date: 2022-03-02 | Comments: 1

Tag: Javascript

Simple HTML date picker is showing not showing calendar icon!
Publish date: 2022-03-01 | Comments: 2

Tag: Javascript

Can we add a javascript or jQuery to the URL?
Publish date: 2022-03-05 | Comments: 2

Tag: Javascript

JAVASCRIPT: How do I add another key to object?
Publish date: 2022-03-06 | Comments: 3

Tag: Javascript

Can I read a local json, image or text file from Javascript?
Publish date: 2022-03-03 | Comments: 1

Tag: Javascript