<!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>
    <title>Bug</title>
<script>
function change(){
document.getElementsByTagName('img')[1].style.display="none";
} </script>
</head>
<body onload="change()">
   <img src=http://www.baidu.com/img/logo.gif>
<br>
<img src=http://www.google.cn/intl/zh-CN/images/logo_cn.gif></body>
</html>

解决方案 »

  1.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>Baidu & Google</title>
    <script language="javascript" type="text/javascript">
    window.onload=function()
    {
      var imgs=document.getElementsByTagName("IMG");
      for(var i=0;i<imgs.length;i++)
      {
          if(imgs[i].src.indexOf("baidu")>0)
      {
        imgs[i].src="http://www.google.cn/intl/zh-CN/images/logo_cn.gif";
      }
      }}
    </script>
    </head>
    <body>
    <img src=http://www.baidu.com/img/logo.gif>
    <br>
    <img src=http://www.google.cn/intl/zh-CN/images/logo_cn.gif>
    </body>
    </html>
      

  2.   

    非常感谢两位!如果:
    已知页面中有一个img标签,并且src属性为"http://www.baidu.com/img/logo.gif"。只有这一个条件的话,那我该怎样才能使得这张图片不显示出来呢?同样不能改动body和/body之间的内容.
      

  3.   

    获得IMG不一定要getElementTagName
    直接 document.images
    返回也是一个数组
      

  4.   

    是不是接二楼的 if(imgs[i].src.indexOf("baidu")>0) 然后
    imgs[i].style.display="none"就可以了呢?