第一个当然出错了,因为你的img对象还没出来,怎么能修改他的值呢。
后面的自然就没错了。

解决方案 »

  1.   

    很正常, 你的处理顺序不对, 你在 hanshu() 执行的时候, <IMG> 还没有被浏览器加载. 所以当然出错
      

  2.   

    那我想问的是对 <a> 元素的处理为什么就没有这个限制
      

  3.   

    哦,是这样的以前被弄晕了
    <html>
       <head>
          <title></title>
          <script>
           function hanshu ( )
              {
                 window.document.anchors [ 0 ].style.top = 200;
                 window.document.all.anchor.style.top = 200;
                 //window.document.anchor.images [ 0 ].style.top = 200;
              }
          </script>
       </head>
       <body>
          <a name="anchor" id="anchor" href="#" style="position:absolute; top:10; left:100;">aaa</a>
          <script>
           hanshu ( );
          </script>
       </body>
    </html>