- 1、本文档共11页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
7.DOM简介
DOM介绍
本文从概念上对DOM进行介绍:它是什么,如何为HTML和XML文本提供相应的结构,如何对DOM进行存取,这个API如何表示基准信息并举例说明。
DOM为何物?
The Document Object Model is an API for HTML and XML documents. It does two things for web developers: it provides a structural representation of the document, and it defines the way that that structure is to be accessed from script, allowing you to get at the web page as a structured group of nodes, which we will discuss shortly. Essentially, it connects web pages to scripts or programming languages.
Note that the DOM is not a particular application, product, or proprietary ordering of web pages. Rather, it is an API, an interface that vendors must implement if they are to be conformant with the W3C DOM standard. Every browser vendor that supports the DOM, just to take one small example, must return all the P elements in an HTML web page as an array of nodes when the getElementsByTagName method is called against that web page in a script:
paragraphs = document.getElementsByTagName(P);
// paragraphs[0] is the first p element
// paragraphs[1] is the second p element, etc.
alert(paragraphs[0].nodeName);
All of the properties, methods, and events available to the web developer for manipulating and creating web pages are organized into objects (e.g., the document object that represents the document itself, the table object that implements that special HTMLTableElement DOM interface for accessing HTML tables, and so forth). This documentation provides an object-by-object reference to those APIs.
DOM vs. JavaScript
The short example above, like all of the examples in this reference, is JavaScript. That is to say, its written in JavaScript, but it uses the DOM to access the web page and its elements. The DOM is not a programming language, but without it, the JavaScript language wouldnt have any model or notion of the web pages, XML pages, and elements with which it is usually concerned. Every element in a document-the document as a whole, the head, tables within the documen
文档评论(0)