[英]To display image using JavaScript
In the code below I have an image in C Directory and I want to display the image on window load using JavaScript. 在下面的代码中,我在C目录中有一个图像,并且我想使用JavaScript在窗口加载时显示该图像。 I tried but image is not displaying.
我试过了,但是图像没有显示。
<div id="thmbDiv"></div>
Script: 脚本:
window.onload=function() {
var thumbContainer = document.getElementById("thmbDiv");
var thumbnail = document.createElement("img");
thumbnail.onload=function() {
thumbContainer.appendChild(thumbnail);
}
thumbnail.src = "C:\Hello\Search\Image0529.jpg";
}
Try 尝试
<div id="thmbDiv"><img id="imageTag" src=""></div>
window.onload=function() {
var thumbnail = document.getElementById("imageTag");
thumbnail.src="C:\Hello\Search\Image0529.jpg";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.