有没有任何onDocumentChange事件? [英] Is there any onDocumentChange event?
本文介绍了有没有任何onDocumentChange事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Internet Explorer中是否有任何事件,DOM更改时会触发?例如:
Is there any event in Internet Explorer, that is fired whenever DOM is changed? For example:
document.attachEvent("ondocumentchange", function () {
alert("you've just changed DOM!");
});
当我执行:
document.appendChild(document.createElement("img"));
带文本的窗口你刚刚更改了DOM!出现。
Window with text "you've just changed DOM!" appears.
我尝试使用Javascript在IE6中模拟高级CSS选择器(例如+,>,[attr])。但是要正确地使用动态内容,他们必须在每次文档更改后重新计算。
I try to emulate "advanced" CSS selectors (e.g. +, >, [attr]) in IE6 using Javascript. However to work properly with dynamic content, they would have to be recalculated after each change in document.
推荐答案
强力解决方案$ {
$ b
Brute-force "solution":
(function (previousInnerHTML) {
return function () {
if (document.body.innerHTML !== previousInnerHTML) {
alert("you've just (at max 33ms ago) changed DOM");
}
setTimout(arguments.callee, 33);
};
})(document.body.innerHTML)();
这篇关于有没有任何onDocumentChange事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文