Document Object Model (DOM) - 在内存中表示文档的结构
文档对象模型(Document Object Model)(DOM) 通过在内存中表示文档的结构(例如表示网页的 HTML),来连接网页和脚本或编程语言。通常它指的是 JavaScript,即使将 HTML、SVG 或 XML 文档建模为对象并不是核心 JavaScript 语言的一部分。
DOM 表示具有逻辑树的文档。树的每个分支都以一个节点结束,每个节点都包含对象。DOM 方法允许以编程方式访问树。使用它们,您可以更改文档的结构、样式或内容。
节点还可以附加事件处理程序。一旦事件被触发,事件处理程序就会被执行。
要了解有关 DOM 是什么以及它如何表示文档的更多信息,请参阅我们的文章 DOM 简介。
DOM 接口
AttrCDATASectionCharacterDataChildNodeCommentCustomEventDocumentDocumentFragmentDocumentTypeDOMErrorDOMExceptionDOMImplementationDOMStringDOMTimeStampDOMStringListDOMTokenListElementEventEventTargetHTMLCollectionMutationObserverMutationRecordNamedNodeMapNodeNodeFilterNodeIteratorNodeListProcessingInstructionSelectionRangeTextTextDecoderTextEncoderTimeRangesTreeWalkerURLWindowWorkerXMLDocument
过时的 DOM 接口
文档对象模型已被高度简化。为了实现这一点,不同 DOM 级别 3 或更早规范中存在的以下接口已被删除。不确定将来是否会重新引入某些内容,但暂时应将其视为过时并应避免使用:
DocumentTouchDOMConfigurationDOMErrorHandlerDOMImplementationListDOMImplementationRegistryDOMImplementationSourceDOMLocatorDOMObjectDOMSettableTokenListDOMUserDataElementTraversalEntityEntityReferenceNameListNotationTypeInfoUserDataHandler
HTML DOM
包含 HTML 的文档是用 Document 接口进行描述的,该接口被HTML规范扩展,包括各种HTML的特定功能。特别是,Element 接口被扩展为 HTMLElement 和各种子类,每个子类代表一个(或一系列密切相关的)元素。
HTML DOM API 提供对各种浏览器功能的访问,例如选项卡和窗口、CSS 样式和样式表、浏览器历史记录等。这些接口在 HTML DOM API 文档中进一步讨论。
SVG 接口
SVG 元素接口
SVGAElementSVGAltGlyphElementSVGAltGlyphDefElementSVGAltGlyphItemElementSVGAnimationElementSVGAnimateElementSVGAnimateColorElementSVGAnimateMotionElementSVGAnimateTransformElementSVGCircleElementSVGClipPathElementSVGComponentTransferFunctionElementSVGCursorElementSVGDefsElementSVGDescElementSVGElementSVGEllipseElementSVGFEBlendElementSVGFEColorMatrixElementSVGFEComponentTransferElementSVGFECompositeElementSVGFEConvolveMatrixElementSVGFEDiffuseLightingElementSVGFEDisplacementMapElementSVGFEDistantLightElementSVGFEDropShadowElementSVGFEFloodElementSVGFEFuncAElementSVGFEFuncBElementSVGFEFuncGElementSVGFEFuncRElementSVGFEGaussianBlurElementSVGFEImageElementSVGFEMergeElementSVGFEMergeNodeElementSVGFEMorphologyElementSVGFEOffsetElementSVGFEPointLightElementSVGFESpecularLightingElementSVGFESpotLightElementSVGFETileElementSVGFETurbulenceElementSVGFilterElementSVGFilterPrimitiveStandardAttributesSVGFontElementSVGFontFaceElementSVGFontFaceFormatElementSVGFontFaceNameElementSVGFontFaceSrcElementSVGFontFaceUriElementSVGForeignObjectElementSVGGElementSVGGeometryElementSVGGlyphElementSVGGlyphRefElementSVGGradientElementSVGGraphicsElementSVGHatchElementSVGHatchpathElementSVGHKernElementSVGImageElementSVGLinearGradientElementSVGLineElementSVGMarkerElementSVGMaskElementSVGMeshElementSVGMeshGradientElementSVGMeshpatchElementSVGMeshrowElementSVGMetadataElementSVGMissingGlyphElementSVGMPathElementSVGPathElementSVGPatternElementSVGPolylineElementSVGPolygonElementSVGRadialGradientElementSVGRectElementSVGScriptElementSVGSetElementSVGStopElementSVGStyleElementSVGSVGElementSVGSwitchElementSVGSymbolElementSVGTextContentElementSVGTextElementSVGTextPathElementSVGTextPositioningElementSVGTitleElementSVGTRefElementSVGTSpanElementSVGUseElementSVGViewElementSVGVKernElement
SVG 数据类型接口
以下是用于定义 SVG 属性和属性的数据类型的 DOM API。
静态类型
SVGAngleSVGColorSVGICCColorSVGElementInstanceSVGElementInstanceListSVGLengthSVGLengthListSVGMatrixSVGNameListSVGNumberSVGNumberListSVGPaintSVGPathSegSVGPathSegClosePathSVGPathSegMovetoAbsSVGPathSegMovetoRelSVGPathSegLinetoAbsSVGPathSegLinetoRelSVGPathSegCurvetoCubicAbsSVGPathSegCurvetoCubicRelSVGPathSegCurvetoQuadraticAbsSVGPathSegCurvetoQuadraticRelSVGPathSegArcAbsSVGPathSegArcRelSVGPathSegLinetoHorizontalAbsSVGPathSegLinetoHorizontalRelSVGPathSegLinetoVerticalAbsSVGPathSegLinetoVerticalRelSVGPathSegCurvetoCubicSmoothAbsSVGPathSegCurvetoCubicSmoothRelSVGPathSegCurvetoQuadraticSmoothAbsSVGPathSegCurvetoQuadraticSmoothRelSVGPathSegListSVGPointSVGPointListSVGPreserveAspectRatioSVGRectSVGStringListSVGTransformSVGTransformList
动画类型
SVGAnimatedAngleSVGAnimatedBooleanSVGAnimatedEnumerationSVGAnimatedIntegerSVGAnimatedLengthSVGAnimatedLengthListSVGAnimatedNumberSVGAnimatedNumberListSVGAnimatedPathDataSVGAnimatedPointsSVGAnimatedPreserveAspectRatioSVGAnimatedRectSVGAnimatedStringSVGAnimatedTransformList
SMIL 相关接口
其他 SVG 接口
GetSVGDocumentShadowAnimationSVGColorProfileRuleSVGCSSRuleSVGDocumentSVGExceptionSVGFitToViewBoxSVGLocatableSVGRenderingIntentSVGUnitTypesSVGUseElementShadowRootSVGViewSpecSVGZoomAndPanSVGZoomEvent
规范
| 规范 | 状态 | 备注 |
|---|---|---|
| DOM | 现行的标准 | - |