<img src="getImageSrc();" alt="11" title="11"/>
function getImageSrc() {
var result = "http://img2.cache.netease.com/cnews/2011/4/19/20110419105506e4696.jpg";
document.write("http://img2.cache.netease.com/cnews/2011/4/19/20110419105506e4696.jpg");
}
这样好像不能成功,请问应该怎么做?
function getImageSrc() {
var result = "http://img2.cache.netease.com/cnews/2011/4/19/20110419105506e4696.jpg";
document.write("http://img2.cache.netease.com/cnews/2011/4/19/20110419105506e4696.jpg");
}
这样好像不能成功,请问应该怎么做?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script></head>
<body>
<img src="" alt="11" title="11" id="test"/>
<script type="text/javascript">
window.onload =function getImageSrc() {
var result = "http://img2.cache.netease.com/cnews/2011/4/19/20110419105506e4696.jpg";
document.getElementById("test").src = result;
}
</script>
</body>
</html>
相当于给img标签的src属性赋值