【发布时间】:2012-03-24 05:50:01
【问题描述】:
我以为没有 DOM 侦听器,所以我实现了自己的“重型”侦听器:
function CvHelper(stackApi) {
var that = this;
// check if room is finished loading
this.init = function() {
if ($('#loading').length) {
setTimeout(that.init, 1000);
} else {
console.log('Chatroom finished loading');
that.postListener();
}
}
}
(function() {
var stackApi = new StackApi();
var cvHelper = new CvHelper(stackApi);
cvHelper.init();
})();
我认为这很糟糕。所以我在 SO 上搜索了这里并弹出了this question。但是last comment on the accepted question 声明它已被弃用。
$("#someDiv").bind("DOMSubtreeModified", function() {
alert("tree changed");
});
w3.org/TR/DOM-Level-3-Events/#event-type-DOMSubtreeModified 表示此事件已被弃用,我们将使用什么来代替?
有替代品吗?
附言它只需要在 Chrome 上运行,因为它是一个 Chrome 扩展程序。
【问题讨论】:
标签: javascript dom google-chrome-extension event-listener dom3