代码如下:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<img   name= "img1"   id= "img1"   src="javascript:showpic();">
</body>
</html><script> 
function   showpic() 

    // 此处"holiday.png"本来是变量值,为了调试方便,设为固定值测试
    document.getElementById("img1").src   = "holiday.png"; 

</script>在IE中图片能够正常显示,而在火狐浏览器、谷歌浏览器中图片不显示。请大家帮忙看看!

解决方案 »

  1.   

    <img name= "img1" id= "img1" src="javascript:showpic();">
    没用过这个用法
      

  2.   

    应该是写法错误<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <body>
    <img name= "img1" id= "img1" src="">
    </body>
    </html><script> 
    function showpic() 

     
      document.getElementById("img1").src = "holiday.png"; 
    } window.onload=showpic;
    </script>这样可以
      

  3.   

    ls 正解  lz可以试试  ls  还有 img标签里的的 src="" 应该不写也可以的  方法中设置了就行。
      

  4.   

    <body>
    <img name= "img1" id= "img1" src="javascript:showpic();">
    </body>src改成onload