I haven't found anything that has worked. I've tried all of the following, to no avail:
target="_blank"
to the <a>
target="someName"
to the <a>
'/'
Meteor.absoluteUrl()
Meteor.absoluteUrl()
with the "http://"
removed<a>
inside {{#constant}}
region in template<a>
not inside {{#constant}}
region in template<a>
in the body outside of any template at all<a>
appended to the body in the browser consolewindow.open([url],[target])
with all the aforementioned combinations.In all cases, the link opens in the same tab as where it was clicked, except for the URLs that didn't start with http://
, which opened an about:blank
page in a new tab.
Any idea what's causing this, or how to solve it?
How to Open Hyperlinks in a New Browser Tab or Window. The short answer is: just add a target="_blank" attribute to your links (anchor tags). Now when your visitors click that link, it will open in a new window or tab (depending on which web browser they are using and how they configured that browser).
To create a new window or tab when a link is clicked, the target="_blank" attribute must be in the a href tag, as shown below.
Open URL in New Tab using JavaScript If you want to open URl in a new tab, you have to use "_blank" in second parameter of window. open().
Use Keyboard with Mouse/Trackpad You can load any link in a new browser tab by clicking or tapping on it while holding down the Control key (Windows) or the Command key (Mac). Each tab loads in the background, so it's an ideal method to open multiple links as you move your way through a webpage.
This seems like a bug. I think Meteor should ignore links with target="_blank"
. Maybe you could create an issue on the issue tracker
That said, I have successfully done this as a work around:
test.html
<template name="test">
<a href="/new-window" target="_blank">Open new window</a>
</template>
test.js
Template.test.events({
'click a[target=_blank]': function (event) {
event.preventDefault();
window.open(event.target.href, '_blank');
}
});
Also, I have found that adding http://
works for external links E.g.
<a href="http://twitter.com" target="_blank">Open new window</a>
I'm not sure why these things didn't work for you. I have only tested them in Chrome, however, so maybe this is a browser issue.
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