【发布时间】:2019-04-15 05:44:41
【问题描述】:
我正在尝试在我的 javascript 和下面显示的 HTML 中的 image 属性之间创建一个链接,该链接指向另一个页面,例如index.html。
这是在框架中,因此更难找到解决方案。
非常感谢任何帮助。
我知道如何使用 href、基本 jquery 等创建链接。但据我所知,这不适用于我的代码。
<a-entity
id="dialog"
position="0 0 -3"
dialog-popup="
image: img/options1.png;
image2: img/play.png;
></a-entity>
generateImage: function generateImage() {
var _this$data5 = this.data,
src = _this$data5.image,
width = _this$data5.imageWidth,
height = _this$data5.imageHeight,
dialogBoxHeight = _this$data5.dialogBoxHeight;
if (!src.length) {
return null;
}
var image = this.imageEl || document.createElement('a-image');
image.setAttribute('id', "".concat(this.el.getAttribute('id'), "--image"));
image.setAttribute('src', src);
image.setAttribute('width', width);
image.setAttribute('height', height);
image.setAttribute('position', {
x: 0,
y: dialogBoxHeight / 2,
z: 0.5
});
this.hasImage = true;
this.imageEl = image;
return image;
},
我能否以某种方式创建一个链接,以便当用户单击图像时,它会使用我的代码将他们带到另一个页面?
我正在尝试定位图像:img/options1.png;和image2:img/play.png;具体来说。
【问题讨论】:
-
所以
<a href="some other page"><img src="some image url"/></a>? -
不,更准确地说我想制作 img/options1.png;和image2:img/play.png;可点击的链接,有什么办法可以做到这一点。
标签: javascript hyperlink var aframe