【发布时间】:2019-02-28 19:11:19
【问题描述】:
从这个答案中获取参考后
我做了同样的代码。
function openImage() {
var largeImage = document.getElementById('viewImage');
largeImage.style.display = 'block';
largeImage.style.width = 200 + "px";
largeImage.style.height = 200 + "px";
var url = largeImage.getAttribute('src');
window.open(url, 'Image', 'width=largeImage.stylewidth,height=largeImage.style.height,resizable=1');
}
但是当这个函数执行时,会显示空白页 当我在控制台中查看图像 src 时,它显示了正确的数据。
你认为我的代码有什么问题?
【问题讨论】:
-
能否提供完整的html代码?
-
你能发布实际的 HTML 内容而不是屏幕截图吗?
-
该解决方案适用于以实际 url 作为 src 的图像,对于以 base64 编码数据作为 src 的图像,请参阅stackoverflow.com/questions/27798126/…
标签: javascript html image window