javascript Internet Explorer 中 MutationObservers 的可用性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13941417/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Availability of MutationObservers in Internet Explorer
提问by ccunni
AFAIK mutation observers are not available yet in IE. Chrome, Safari, Firefox have their implementations and its working its way through the standardization process. I'm wondering if anyone (preferably MS employee) knows the story with IE, or might give me a pointer to an article I missed.
AFAIK 突变观察者在 IE 中尚不可用。Chrome、Safari、Firefox 都有它们的实现,并且它们在标准化过程中发挥着作用。我想知道是否有人(最好是 MS 员工)知道 IE 的故事,或者可能会给我一个我错过的文章的指针。
回答by PHPst
IE 11 supports MutationObservers
natively. For IE 9-10 you can use this polyfill:
https://github.com/Polymer/MutationObservers
IE 11 原生支持MutationObservers
。对于 IE 9-10,你可以使用这个 polyfill:https:
//github.com/Polymer/MutationObservers
回答by Paul Sweatte
There's a recent article on Windows 8app development which uses onpropertychange
to handle DOM mutation.
最近有一篇关于Windows 8应用程序开发的文章onpropertychange
用于处理 DOM 突变。
Example 4: Handle onpropertychange for ARIA-selected property to detect programmatic change of tab selection.
示例 4:处理 ARIA 选择的属性的 onpropertychange 以检测选项卡选择的编程更改。
tabElement.attachEvent("onpropertychange", selectionChanged);
function selectionChanged(event)
{
if (event.propertyName === "aria-selected")
{
if (event.srcElement.getAttribute("aria-selected") === "true")
{
// execute code to load the content that corresponds with the selected tab element
}
else
{
// execute code for deselected tab, if needed
}
}
}
References
参考
回答by Won Jun Bae
For compatibility with IE9-10, https://github.com/webmodules/mutation-observerexposes the native MutationObserver API provided by the browser, or a polyfill based on mutation events.
为了与 IE9-10 兼容,https://github.com/webmodules/mutation-observer公开了浏览器提供的原生 MutationObserver API,或基于突变事件的polyfill 。