The following
button(type="button", target="_blank", onclick="location.href='auth/google';")
does not work. It opens link in the same window. Just for reference, its part of node.js program, in which i'm using passportjs for google authentication.
The button isn't actually opening a link - it's just running some javascript code that happens to, in this instance, be navigating to a new URL. So the target="_blank"
attribute on the button won't help.
Instead, you need to use javascript commands to open a new tab/window, rather than using javascript to change the URL of the current window. Assigning to location.href
will only change the URL of the current window.
Use the window.open(url, target)
function instead - it takes a URL, and a target window name, which behaves the same as the target="whatever"
attribute on a link.
window.open('auth/google', '_blank');
Your complete code would look like this:
button(type="button", onclick="window.open('auth/google', '_blank');")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With