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

What is the use of package-lock JSON file?
Publish date: 2022-02-11 | Comments: 3

Tag: Javascript

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

Tag: Javascript

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

Tag: Javascript

Vanilla JavaScript Next & prev Navigation
Publish date: 2022-02-22 | Comments: 1

Tag: Javascript

How do I check if an array includes a value in JavaScript?
Publish date: 2022-02-13 | Comments: 2

Tag: Javascript

How can I switch between two background-colors using js setinterval( )
Publish date: 2022-02-22 | Comments: 1

Tag: Javascript

Coping plain text into form bug.
Publish date: 2022-02-11 | Comments: 1

Tag: Javascript

Required to convert Obj {} to Arr [] from key-value pairs using javascript
Publish date: 2022-03-06 | Comments: 2

Tag: Javascript