karthik
karthik

Reputation: 81

React router open route in new window

I am trying to open a route in a new window upon a hyperlink click. target=_blank is not of much help since I am trying to open in new window, not new tab. window.open also opens in a new tab. Is this at all possible?

Upvotes: 2

Views: 16086

Answers (1)

Paolo Dell'Aguzzo
Paolo Dell'Aguzzo

Reputation: 1431

You can use this to open a new window:

window.open('http://www.google.com', '_blank', 'toolbar=0,location=0,menubar=0');

If you have different urls (dev env, test env, prod env) you can use this to get the base url:

window.location.origin

So final code is:

window.open(window.location.origin + "/ROUTE_U_WANT", '_blank', 'toolbar=0,location=0,menubar=0');

Upvotes: 15

Related Questions