【问题标题】:Javascript display image from uri来自uri的Javascript显示图像
【发布时间】:2015-10-07 21:58:01
【问题描述】:

作为 Javascript 代码的一部分,在获取 uri 后,我尝试从该 uri 获取图像,并将其插入到行首的单元格中。下面是我的代码。它不起作用。我无法弄清楚我做错了什么/如何实现这一目标。我需要使用 XMLHttpRequest() 还是可以只使用源 uri 创建图像?有人可以帮忙吗?提前谢谢了!我也在代码中注释了。

    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

【问题讨论】:

    标签: javascript html image load uri


    【解决方案1】:

    我注意到的第一件事是你有 img.scr 而不是 img.src

    【讨论】:

    • 天哪,这是一个愚蠢的错误。谢谢你,小伙伴!!我花了大约一个小时在这上面。几分钟后我会接受你的回答
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-20
    相关资源
    最近更新 更多