最近本人在研究别人代码的时候,发现有些地方用到document这个对象,请问关于这个document一般用在什么地方?
难道是处理文件方面的吗?他有哪些方法?有谁能详细得跟我讲解下,谢谢了~

解决方案 »

  1.   

    你说的应该是网页里面的吧,那个是javascript的document对象,指代那个网页的。具体解释(摘自javascript语言参考手册):An HTML document consists of HEAD and BODY tags. The HEAD tag includes information on the document's title and base (the absolute URL base to be used for relative URL links in the document). The BODY tag encloses the body of a document, which is defined by the current URL. The entire body of the document (all other HTML elements for the document) goes within the BODY tag.
    You can load a new document by setting the Window.location property.You can clear the document pane (and remove the text, form elements, and so on so they do not redisplay) with these statements:document.close();
    document.open();
    document.write(); You can omit the document.open call if you are writing text or HTML, since write does an implicit open of that MIME type if the document stream is closed.You can refer to the anchors, forms, and links of a document by using the anchors, forms, and links arrays. These arrays contain an entry for each anchor, form, or link in a document and are properties of the document object.Do not use location as a property of the document object; use the document.URL property instead. The document.location property, which is a synonym for document.URL, will be removed in a future release.
      

  2.   

    document 在使用 搜索引擎 lucene 的时候也存在 , 是把数据库表内容 或 其他文本内容 进行分词,存储为lucene自己的数据库 , 这个document就相当于lucene自己数据库的表。有些add 方法创建行 和列
      

  3.   

    实际上这个document就是把数据组成表格的形式。
      

  4.   

    所有的HTML网页都可以看作一颗倒立的树来解析,也就是DOM(DOCUMENT OBJECT MODEL)。用的最多的方法就是document.getElementById(),document.getElementByTagNames()这两个方法。根据方法的名字就可以看出它们的作用就是分别根据ID或NAME来获取对应的元素。
      

  5.   


    貌似楼主看到的是 JavaScript 的document ......不是 Java 里的document如果是Javascript里边的document 那么这个document指的就是整个html页面 。 因为html页面是xml的子类。 所以html也是类似树形结构的 , 可以使用javascript 以访问xml的形式访问html .document.getElementById()是访问节点效率最高的。
    由于dom访问的方式是冒泡式遍历 所以也会出现 事件冒泡 用JavaScript处理事件时应当注意,取消事件冒泡在IE和firfox不同。又啰嗦一堆
      

  6.   

    js里面呀,用document获取界面元素数据,还有一个windows对象
      

  7.   

    谢谢各位的回答,的确,在JS中document用得很多。
      

  8.   

     建议楼主看看 javascrpit编程艺术或者搜下 w3cscholl 上面讲的比较详细