Reputation: 89
this is specific to A-Frame.
I'm creating an a-link from javascript code:
var alinkEl = document.createElement('a-link');
alinkEl.setAttribute('href', 'http://www.facebook.com/share.php?u=https://.../' + folder + fileName);
This does not work:
alinkEl.setAttribute('target', '_blank');
Any hint?
Upvotes: 3
Views: 1541
Reputation: 162
Make sure you have placed an <a-cursor>
element to trigger the click event.
Upvotes: 0
Reputation: 14645
The <a-link>
s are intended for link traversal as far as i know, not for opening new tabs. The component does not have a target
attribute in the schema. Furthermore, the navigation is implemented like this:
navigate: function () {
window.location = this.data.href;
}
So You only change the location of the given window.
portal
shader, and set the pano
attribute:
<a-circle position="0 3.5 -2"
material="shader:portal;pano:_URL_TO_PORTAL_IMAGE"
></a-circle>
If You want it to open a new tab, make Your own component:
AFRAME.registerComponent('foo', {
init: function() {
this.el.addEventListener('click', (e) => {
window.open('https://ebay.com');
})
}
})
And attach it to Your portal:
<a-circle position="0 3.5 -2" material="shader:portal;pano:_URL_TO_PANO"
foo></a-circle>
Working fiddle here.
Upvotes: 4
Reputation: 58
It looks like the <a-link>
primitive does not have the "target" attribute.
But there is an npm package that supports that. It's called aframe-href-component and can be found here: https://www.npmjs.com/package/aframe-href-component
Upvotes: 2
Reputation: 4094
a-link does not support a target
property according to https://aframe.io/docs/0.6.0/components/link.html
Upvotes: 0