其实有时差不多地,不过你多试试
具体我也说不上来
document是获得文档的所有属性<a id="aaa" name="aaa">aa</a>
<script>
alert(aaa.innerText)
alert(document.all.aaa.innerText)
</script>

解决方案 »

  1.   

    可以这么用是对的,但为什么可以这么用啊?在DOM规范里应当有可以这么用的依据才对啊?
      

  2.   

    IDL Definition 
    interface Document : Node {
      readonly attribute DocumentType     doctype;
      readonly attribute DOMImplementation  implementation;
      readonly attribute Element          documentElement;
      Element            createElement(in DOMString tagName)
                                            raises(DOMException);
      DocumentFragment   createDocumentFragment();
      Text               createTextNode(in DOMString data);
      Comment            createComment(in DOMString data);
      CDATASection       createCDATASection(in DOMString data)
                                            raises(DOMException);
      ProcessingInstruction createProcessingInstruction(in DOMString target, 
                                                        in DOMString data)
                                            raises(DOMException);
      Attr               createAttribute(in DOMString name)
                                            raises(DOMException);
      EntityReference    createEntityReference(in DOMString name)
                                            raises(DOMException);
      NodeList           getElementsByTagName(in DOMString tagname);
    };这是在DOM中的关于DOCUMENT基类的定义
      

  3.   

    interface HTMLDocument : Document {
               attribute DOMString        title;
      readonly attribute DOMString        referrer;
      readonly attribute DOMString        domain;
      readonly attribute DOMString        URL;
               attribute HTMLElement      body;
      readonly attribute HTMLCollection   images;
      readonly attribute HTMLCollection   applets;
      readonly attribute HTMLCollection   links;
      readonly attribute HTMLCollection   forms;
      readonly attribute HTMLCollection   anchors;
               attribute DOMString        cookie;
      void               open();
      void               close();
      void               write(in DOMString text);
      void               writeln(in DOMString text);
      Element            getElementById(in DOMString elementId);
      NodeList           getElementsByName(in DOMString elementName);
    };
    这是DOCUMENT基类在HTML中的扩展类的定义,平常我们调用的DOCUMENT就是这个类,但是不管在基类或者是扩展类中我们都找不到all这个集合属性的定义,这是为什么啊?