<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"); 
    }
这样好像不能成功,请问应该怎么做?

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <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>
      

  2.   

    1楼的可以了,你那样肯定是不对的
    相当于给img标签的src属性赋值
      

  3.   

    document.write(result)不行吗?