SVGElement

All of the SVG DOM interfaces that correspond directly to elements in the SVG language derive from the SVGElement 接口。

特性

Also inherits properties from: DocumentAndElementEventHandlers , Element , ElementCSSInlineStyle , GlobalEventHandlers , HTMLOrForeignElement , SVGElementInstance

SVGElement.dataset 只读
A DOMStringMap object which provides a list of key/value pairs of named data attributes which correspond to custom data attributes attached to the element. These can also be defined in SVG using attributes of the form data-* , where * is the key name for the pair. This works just like HTML's HTMLElement.dataset property and HTML's data-* global attribute.
SVGElement.className 只读
An SVGAnimatedString that reflects the value of the class attribute on the given element, or the empty string if class is not present. This attribute is deprecated and may be removed in a future version of this specification. Authors are advised to use Element.classList 代替。
SVGElement.ownerSVGElement 只读
An SVGSVGElement referring to the nearest ancestor <svg> 元素。 null if the given element is the outermost <svg> 元素。
SVGElement.viewportElement 只读
SVGElement , which established the current viewport. Often, the nearest ancestor <svg> 元素。 null if the given element is the outermost <svg> 元素。

方法

This interface has no methods, but inherits methods from: DocumentAndElementEventHandlers , Element , ElementCSSInlineStyle , GlobalEventHandlers , HTMLOrForeignElement , SVGElementInstance

Events

监听这些事件使用 addEventListener() or by assigning an event listener to the equivalent on... handler property defined on GlobalEventHandlers or WindowEventHandlers .

abort
Fired when page loading is stopped before an SVG element has been allowed to load completely.
Also available via the onabort 特性。
error
Fired when an SVG element does not load properly or when an error occurs during script execution.
Also available via the onerror 特性。
load
Fires on an SVGElement when it is loaded in the browser.
Also available via the onload 特性。
resize
Fired when an SVG document is being resized.
Also available via the onresize 特性。
scroll
Fired when an SVG document view is being shifted along the X and/or Y axes.
Also available via the onscroll 特性。
unload
Fired when the DOM implementation removes an SVG document from a window or frame.
Also available via the onunload 特性。

规范

规范 状态 Comment
Scalable Vector Graphics (SVG) 2
The definition of 'SVGElement' in that specification.
候选推荐 添加 dataset 特性。
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'SVGElement' in that specification.
Recommendation 初始定义

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
SVGElement Chrome Yes Edge 12 Firefox Yes IE 9 Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
abort event Chrome ? Edge ? Firefox ? IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
dataset Chrome 55 Edge 17 Firefox 51 IE No Opera 41 Safari 10 WebView Android 55 Chrome Android 55 Firefox Android 51 Opera Android 41 Safari iOS 10 Samsung Internet Android 6.0
error event Chrome ? Edge ? Firefox ? IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
focus Chrome Yes Edge ≤79 Firefox 51 IE ? Opera Yes Safari ? WebView Android Yes Chrome Android Yes Firefox Android 51 Opera Android Yes Safari iOS ? Samsung Internet Android Yes
load event Chrome Yes Edge ≤79 Firefox Yes
Alternate Name
Yes
Alternate Name
Alternate Name Uses the non-standard name: SVGLoad
IE ? Opera ? Safari ? WebView Android Yes Chrome Android Yes Firefox Android Yes
Alternate Name
Yes
Alternate Name
Alternate Name Uses the non-standard name: SVGLoad
Opera Android ? Safari iOS ? Samsung Internet Android Yes
offsetHeight
弃用 非标
Chrome ? — 50 Edge No Firefox No IE No Opera ? — 37 Safari No WebView Android ? — 50 Chrome Android ? — 50 Firefox Android No Opera Android ? — 37 Safari iOS No Samsung Internet Android ? — 5.0
offsetLeft
弃用 非标
Chrome ? — 50 Edge No Firefox No IE No Opera ? — 37 Safari No WebView Android ? — 50 Chrome Android ? — 50 Firefox Android No Opera Android ? — 37 Safari iOS No Samsung Internet Android ? — 5.0
offsetParent
弃用 非标
Chrome ? — 50 Edge No Firefox No IE No Opera ? — 37 Safari No WebView Android ? — 50 Chrome Android ? — 50 Firefox Android No Opera Android ? — 37 Safari iOS No Samsung Internet Android ? — 5.0
offsetTop
弃用 非标
Chrome ? — 50 Edge No Firefox No IE No Opera ? — 37 Safari No WebView Android ? — 50 Chrome Android ? — 50 Firefox Android No Opera Android ? — 37 Safari iOS No Samsung Internet Android ? — 5.0
offsetWidth
弃用 非标
Chrome ? — 50 Edge No Firefox No IE No Opera ? — 37 Safari No WebView Android ? — 50 Chrome Android ? — 50 Firefox Android No Opera Android ? — 37 Safari iOS No Samsung Internet Android ? — 5.0
resize event Chrome Yes Edge ≤79 Firefox Yes IE ? Opera ? Safari ? WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android ? Safari iOS ? Samsung Internet Android Yes
scroll event Chrome ? Edge ? Firefox ? IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
unload event Chrome ? Edge ? Firefox ? IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知
非标。预期跨浏览器支持较差。
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
弃用。不要用于新网站。
使用非标名称。

另请参阅

  1. SVGElement
  2. 特性
    1. onabort
    2. onanimationcancel
    3. onanimationend
    4. onanimationiteration
    5. onauxclick
    6. onblur
    7. oncancel
    8. oncanplay
    9. oncanplaythrough
    10. onchange
    11. onclick
    12. onclose
    13. oncontextmenu
    14. oncuechange
    15. ondblclick
    16. ondurationchange
    17. onended
    18. onerror
    19. onfocus
    20. onformdata
    21. ongotpointercapture
    22. oninput
    23. oninvalid
    24. onkeydown
    25. onkeypress
    26. onkeyup
    27. onload
    28. onloadeddata
    29. onloadedmetadata
    30. onloadend
    31. onloadstart
    32. onlostpointercapture
    33. onmousedown
    34. onmouseenter
    35. onmouseleave
    36. onmousemove
    37. onmouseout
    38. onmouseover
    39. onmouseup
    40. onpause
    41. onplay
    42. onplaying
    43. onpointercancel
    44. onpointerdown
    45. onpointerenter
    46. onpointerleave
    47. onpointermove
    48. onpointerout
    49. onpointerover
    50. onpointerup
    51. onreset
    52. onresize
    53. onscroll
    54. onselect
    55. onselectionchange
    56. onselectstart
    57. onsubmit
    58. ontouchcancel
    59. ontouchstart
    60. ontransitioncancel
    61. ontransitionend
    62. onwheel
  3. 继承:
    1. Element
    2. Node
    3. EventTarget
  4. Related pages for SVG
    1. SVGAElement
    2. SVGAltGlyphElement
    3. SVGAngle
    4. SVGAnimateColorElement
    5. SVGAnimateElement
    6. SVGAnimateMotionElement
    7. SVGAnimateTransformElement
    8. SVGAnimatedAngle
    9. SVGAnimatedBoolean
    10. SVGAnimatedEnumeration
    11. SVGAnimatedInteger
    12. SVGAnimatedLength
    13. SVGAnimatedLengthList
    14. SVGAnimatedNumber
    15. SVGAnimatedNumberList
    16. SVGAnimatedPathData
    17. SVGAnimatedPoints
    18. SVGAnimatedPreserveAspectRatio
    19. SVGAnimatedRect
    20. SVGAnimatedString
    21. SVGAnimatedTransformList
    22. SVGAnimationElement
    23. SVGCircleElement
    24. SVGClipPathElement
    25. SVGComponentTransferFunctionElement
    26. SVGCursorElement
    27. SVGDefsElement
    28. SVGDescElement
    29. SVGDocument
    30. SVGEllipseElement
    31. SVGFEBlendElement
    32. SVGFEColorMatrixElement
    33. SVGFEComponentTransferElement
    34. SVGFECompositeElement
    35. SVGFEConvolveMatrixElement
    36. SVGFEDiffuseLightingElement
    37. SVGFEDisplacementMapElement
    38. SVGFEDistantLightElement
    39. SVGFEDropShadowElement
    40. SVGFEFloodElement
    41. SVGFEFuncAElement
    42. SVGFEFuncBElement
    43. SVGFEFuncGElement
    44. SVGFEFuncRElement
    45. SVGFEGaussianBlurElement
    46. SVGFEImageElement
    47. SVGFEMergeElement
    48. SVGFEMergeNodeElement
    49. SVGFEMorphologyElement
    50. SVGFEOffsetElement
    51. SVGFEPointLightElement
    52. SVGFESpecularLightingElement
    53. SVGFESpotLightElement
    54. SVGFETileElement
    55. SVGFETurbulenceElement
    56. SVGFilterElement
    57. SVGFilterPrimitiveStandardAttributes
    58. SVGFitToViewBox
    59. SVGFontElement
    60. SVGFontFaceElement
    61. SVGFontFaceFormatElement
    62. SVGFontFaceNameElement
    63. SVGFontFaceSrcElement
    64. SVGFontFaceUriElement
    65. SVGForeignObjectElement
    66. SVGGElement
    67. SVGGlyphElement
    68. SVGGradientElement
    69. SVGGraphicsElement
    70. SVGHKernElement
    71. SVGImageElement
    72. SVGLength
    73. SVGLengthList
    74. SVGLineElement
    75. SVGLinearGradientElement
    76. SVGMPathElement
    77. SVGMarkerElement
    78. SVGMaskElement
    79. SVGMatrix
    80. SVGMetadataElement
    81. SVGMissingGlyphElement
    82. SVGNumber
    83. SVGNumberList
    84. SVGPathElement
    85. SVGPathSeg
    86. SVGPathSegArcAbs
    87. SVGPathSegArcRel
    88. SVGPathSegClosePath
    89. SVGPathSegCurvetoCubicAbs
    90. SVGPathSegCurvetoCubicRel
    91. SVGPathSegCurvetoCubicSmoothAbs
    92. SVGPathSegCurvetoCubicSmoothRel
    93. SVGPathSegCurvetoQuadraticAbs
    94. SVGPathSegCurvetoQuadraticRel
    95. SVGPathSegCurvetoQuadraticSmoothAbs
    96. SVGPathSegCurvetoQuadraticSmoothRel
    97. SVGPathSegLinetoAbs
    98. SVGPathSegLinetoHorizontalAbs
    99. SVGPathSegLinetoHorizontalRel
    100. SVGPathSegLinetoRel
    101. SVGPathSegLinetoVerticalAbs
    102. SVGPathSegLinetoVerticalRel
    103. SVGPathSegList
    104. SVGPathSegMovetoAbs
    105. SVGPathSegMovetoRel
    106. SVGPatternElement
    107. SVGPoint
    108. SVGPointList
    109. SVGPolygonElement
    110. SVGPolylineElement
    111. SVGPreserveAspectRatio
    112. SVGRadialGradientElement
    113. SVGRect
    114. SVGRectElement
    115. SVGSVGElement
    116. SVGScriptElement
    117. SVGSetElement
    118. SVGStopElement
    119. SVGStringList
    120. SVGStylable
    121. SVGStyleElement
    122. SVGSwitchElement
    123. SVGSymbolElement
    124. SVGTRefElement
    125. SVGTSpanElement
    126. SVGTests
    127. SVGTextContentElement
    128. SVGTextElement
    129. SVGTextPathElement
    130. SVGTextPositioningElement
    131. SVGTitleElement
    132. SVGTransform
    133. SVGTransformList
    134. SVGTransformable
    135. SVGURIReference
    136. SVGUnitTypes
    137. SVGUseElement
    138. SVGVKernElement
    139. SVGViewElement
    140. SVGZoomAndPan
    141. SVGZoomEvent
    142. TimeEvent