[英]Javascript display image from uri
As part of Javascript code, after getting the uri, I tried to get an image from that uri, and insert it into a cell at the beginning of a row. 作为Javascript代码的一部分,在获取uri后,我尝试从该uri获取图像,并将其插入到行开头的单元格中。 Below is my code.
下面是我的代码。 It doesn't work.
没用 I couldn't figure out what I've done wrong/ how to achieve this.
我不知道我做错了什么/如何实现这一目标。 Do I need to use a XMLHttpRequest() or can I just create an image with source uri?
我需要使用XMLHttpRequest()还是可以仅使用源uri创建图像? Can someone please help?
有人可以帮忙吗? Many thanks in advance!
提前谢谢了! I commented in the code as well.
我也在代码中评论了。
var rowx =document.getElementById(rowid); //get that row that I want to insert image
var x =rowx.insertCell(0); //insert a cell
var uri= "baseuri"+rowid; //this is the uri where I get the image from
img = document.createElement('img');
img.scr= uri;
x.appendChild(img); //I tried x.innerHTML = img, but that didn't work either
我注意到的第一件事是您拥有img.scr
而不是img.src
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.