A框架:如何在_blank页面中打开动态创建的A链接 [英] A-Frame : How to open a dynamically created a-link in a _blank page
本文介绍了A框架:如何在_blank页面中打开动态创建的A链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是特定于A框架的。
我正在根据JavaScript代码创建一个A-link:
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);
这不起作用:
alinkEl.setAttribute('target', '_blank');
有任何提示吗?
推荐答案
据我所知,< a-link>
用于链接遍历,而不用于打开新标签。该组件在架构中没有 target
属性。此外,导航的实现方式如下:
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;
}
因此,您只更改给定窗口的位置。
要打开新选项卡,我将创建门户网站,并自己链接:
如果要门户网站,请使用
portal
着色器,并设置 pano
属性:
So You only change the location of the given window.
To open a new tab I would would do the portal, and the link myself:
If You want a portal use the
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>
工作小提琴此处。
这篇关于A框架:如何在_blank页面中打开动态创建的A链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文