使用javascript在运行时显示图像 [英] display image at runtime using javascript

查看:107
本文介绍了使用javascript在运行时显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在运行时使用javascript显示图像.
以下代码不起作用.为什么?

How to display image at runtime using javascript.
following code is not work.why?

function changePic(strPath)
{
    alert(strPath);
    document.getElementById('ctl00_ContentPlaceHolderTM_imgAddPhoto').src=strPath;
}

推荐答案

此代码正确.
This code is correct.
document.getElementById(''ctl00_ContentPlaceHolderTM_imgAddPhoto'').src=strPath;



只要图像路径正确,这肯定会起作用,并且图像会相应显示.确保路径上存在图像.通常,这是因为形成了错误的相对路径.纠正它,它将起作用.



This would surely work and image would be displayed accordingly as long as the image path is correct. Make sure an image exists on the path. Mostly, it would be because of wrong relative path formed. Correct it and it would work.


这篇关于使用javascript在运行时显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆