Range.detach() method does nothing. It used to disable the 范围 object and enable the browser to release associated resources. The method has been kept for compatibility.

句法

range.detach();
					

范例

var range = document.createRange();
range.selectNode(document.getElementsByTagName("div").item(0));
range.detach();
					

规范

规范 状态 注释
DOM
The definition of 'Range.detach()' in that specification.
实时标准 无变化。
Document Object Model (DOM) Level 2 Traversal and Range Specification
The definition of 'Range.detach()' in that specification.
过时 最初的规范。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
detach Chrome Yes
Yes
Since April 2014 this method is a no-op in Chrome .
Edge 12 Firefox 4 — 15
不支持 4 — 15
Starting in Firefox 15.0, this method is a no-op and has no effect.
IE 9 Opera 9 Safari Yes
Yes
Since August 2015 this method is a no-op in WebKit-based browsers .
WebView Android Yes Chrome Android Yes Firefox Android 4 — 15
不支持 4 — 15
Starting in Firefox 15.0, this method is a no-op and has no effect.
Opera Android Yes Safari iOS Yes
Yes
Since August 2015 this method is a no-op in WebKit-based browsers .
Samsung Internet Android Yes

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

另请参阅

元数据

  • 最后修改:
  1. DOM (文档对象模型)
  2. 范围
  3. 构造函数
    1. Range()
  4. 特性
    1. collapsed
    2. commonAncestorContainer
    3. endContainer
    4. endOffset
    5. startContainer
    6. startOffset
  5. 方法
    1. cloneContents()
    2. cloneRange()
    3. collapse()
    4. compareBoundaryPoints()
    5. compareNode()
    6. comparePoint()
    7. createContextualFragment()
    8. deleteContents()
    9. detach()
    10. extractContents()
    11. getBoundingClientRect()
    12. getClientRects()
    13. insertNode()
    14. intersectsNode()
    15. isPointInRange()
    16. selectNode()
    17. selectNodeContents()
    18. setEnd()
    19. setEndAfter()
    20. setEndBefore()
    21. setStart()
    22. setStartAfter()
    23. setStartBefore()
    24. surroundContents()
    25. toString()
  6. 继承:
    1. AbstractRange
  7. DOM 相关页面
    1. AbortController
    2. AbortSignal
    3. AbstractRange
    4. Attr
    5. ByteString
    6. CDATASection
    7. CSSPrimitiveValue
    8. CSSValue
    9. CSSValueList
    10. CharacterData
    11. ChildNode
    12. 注释
    13. CustomEvent
    14. DOMConfiguration
    15. DOMError
    16. DOMErrorHandler
    17. DOMException
    18. DOMImplementation
    19. DOMImplementationList
    20. DOMImplementationRegistry
    21. DOMImplementationSource
    22. DOMLocator
    23. DOMObject
    24. DOMParser
    25. DOMPoint
    26. DOMPointInit
    27. DOMPointReadOnly
    28. DOMRect
    29. DOMString
    30. DOMTimeStamp
    31. DOMTokenList
    32. DOMUserData
    33. Document
    34. DocumentFragment
    35. DocumentType
    36. 元素
    37. ElementTraversal
    38. Entity
    39. EntityReference
    40. 事件
    41. EventTarget
    42. HTMLCollection
    43. MutationObserver
    44. 节点
    45. NodeFilter
    46. NodeIterator
    47. NodeList
    48. NonDocumentTypeChildNode
    49. ProcessingInstruction
    50. PromiseResolver
    51. StaticRange
    52. 文本
    53. TextDecoder
    54. TextEncoder
    55. TimeRanges
    56. TreeWalker
    57. TypeInfo
    58. USVString
    59. UserDataHandler
    60. XMLDocument

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1