Reputation: 325
I want to use node js redirect to the url and display the url in a new browser, can that be happening?
Upvotes: 4
Views: 27384
Reputation: 21
One small trick that works for is, I have a redirect on the link which I want to open in a new tab.
And added target="_blank"
in my form
<form method='post' action="/post/URL" target="_blank">
...
</form>
Upvotes: 1
Reputation: 992
The easiest way to do this cross browser is to use the "open" npm module This module allows you to open a new browser window and designate a url to go to
npm install open --save
then in your request when you want to open the new browser and load the url simply call
open( 'http://urltodirect.to', function (err) {
if ( err ) throw err;
});
That will open a new browser window and send the tab to http://urltodirect.to
Hope this helps!
Upvotes: 4
Reputation: 1007
You can redirect to a new URL with Node as part of a server request if you use the Express framework's redirect method.
However you can't display the URL in a new browser with Node, as this is front-end work. You could use target=_blank
within your HTML link in order to do this.
Upvotes: 1
Reputation: 22016
Node Js is a server side technology which can redirect the browsers request to a new location but cannot instructed the browser to open a new window.
You need to use client side javascript to ask the browser to open another window see here:
http://www.w3schools.com/jsref/met_win_open.asp
or use target="_blank" within the link itself.
Upvotes: 2