document.all ? document.all["RequiredFieldValidator1"] : document.getElementById("RequiredFieldValidator1");很多地方看到这样用
为什么不直接document.getElementById("RequiredFieldValidator1");而要先判断是否支持document.all呢?
IE中不也是支持document.getElementById("RequiredFieldValidator1");的吗?  

解决方案 »

  1.   

    瀏覽器版本不一定支持 getElementById
    所以如果直接用的話有可能會出錯。。
      

  2.   

    document.all倒是ie only的东西
    document.getElementById()是标准。近现代的浏览器都支持
    而且bug相对较少document.all一般用来判断是浏览器类型的
      

  3.   

    有浏览器不支持document.getElementById()吗?
      

  4.   

    现在在用的浏览器没有
    起码他的适用性远远超过document.all