问题描述
如何在mako模板内的新窗口中打开图像(其URL为mako变量)?我想要最简单的东西。这就是我要使用的:
yourappname.bluemix.net
但是,没有新的窗口打开,上面的代码...还有其他方法可以实现吗?
解决方法
您可以尝试在onclick属性中的图片网址周围加上引号。我已将openImage(${image_to_open_url})
替换为openImage('${image_to_open_url}')
。我认为它无法像您所拥有的那样裸露。
<script>
function openImage(image_url) {
window.open('_blank').document.write('<img src="' + image_url + '">');
}
</script>
<a href="#"><img src="${image_overview_url}" onclick="openImage('${image_to_open_url}');"></a>
,
如果您在链接中添加了对图片的引用,并且使用了target="_blank"
,就可以使用。
<a href="${image_overview_url}" target="_blank"><img src="${image_overview_url}"></a>