过时
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

NodeIterator.detach() method is a no-op, kept for backward compatibility only.

Originally, it detached the NodeIterator from the set over which it iterates, releasing any resources used by the set and setting the iterator's state to INVALID . Once this method had been called, calls to other methods on NodeIterator would raise the INVALID_STATE_ERR 异常。

句法

nodeIterator.detach();
					

范例

var nodeIterator = document.createNodeIterator(
    document.body,
    NodeFilter.SHOW_ELEMENT,
    { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } },
    false
);
nodeIterator.detach(); // detaches the iterator
nodeIterator.nextNode(); // throws an INVALID_STATE_ERR exception
					

规范

规范 状态 注释
DOM
The definition of 'NodeIterator.detach' in that specification.
实时标准 Transformed in a no-op
Document Object Model (DOM) Level 2 Traversal and Range Specification
The definition of 'NodeIterator.detach' in that specification.
过时 初始定义。

浏览器兼容性

The compatibility table in 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 1 Edge 12 Firefox 3.5 — 22 IE 9 Opera 9 Safari 3 WebView Android Yes Chrome Android Yes Firefox Android 4 — 22 Opera Android 10.1 Safari iOS 3 Samsung Internet Android Yes

图例

完整支持

完整支持

不支持

不支持

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

弃用。不要用于新网站。

弃用。不要用于新网站。

另请参阅

元数据

  • 最后修改: