Reputation: 2780
I want to write a Firefox add-on.
I need to monitor the contents of a DIV element.
Is there a way to put a hook or subscribe to the modification of a certain HTML element?
I don't want to poll the contents of the DIV (per say) every second, would be nice to be notified when it is changed.
Thank you.
Upvotes: 0
Views: 425
Reputation: 2780
Found how to do this!
function onLoadDoThings(){
document.getElementById('changingDiv').addEventListener('DOMSubtreeModified',function(){
alert(document.getElementById('changingDiv').innerHTML);
}
,false);
}
Upvotes: 2
Reputation: 55447
Instead of writing an extension have you thought about writing a Greasemonkey script? Much easier and no compiler needed. I've also seen programs that can convert scripts to XPI's but haven't tried them.
Upvotes: 0