<script name=script1>
function checkall()
{
  var owin=window.open("","_blank");
  owin.document.write("下面的内容在ie8中可以显示,在firefox9中不可以,不知道为什么");
  owin.document.write(document.images("img1").src+"<br>");
  owin.document.write(document.images.item("img2").src+"<br>");
  var objImg=document.images.item("sample");
  if(objImg!=null)
  {
  if(objImg.length!=null)
  {
  for(var i=0;i<objImg.length;i++)
  {
  owin.document.write(objImg[i].src+"<br>");  
  }
  }
  }
}
</script>
<body onload="checkall()">
<img src="sample1.gif" name=sample id=img1>
<img src="sample2.gif" name=sample id=img2>
</body>

解决方案 »

  1.   

    Uncaught TypeError: Property 'images' of object #<HTMLDocument> is not a functiondocument.images(  没这个方法
      

  2.   

      owin.document.write(document.images["img1"].src+"<br>");
      var objImg=document.images["sample"];
      

  3.   

    用 getElementById
    或者 getElementsByTagName 
      

  4.   

    这是张孝祥视频里面的一个例子,他说元素的name相同的时候可以使用document.images.item(name名字);来获得这个name的所有的元素的信息。
    var objImg=document.images.item("sample");这种用法在文档里面怎么没找到,是不是不能这么用?