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 sub开发者_如何转开发scribe 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.
Found how to do this!
function onLoadDoThings(){
document.getElementById('changingDiv').addEventListener('DOMSubtreeModified',function(){
alert(document.getElementById('changingDiv').innerHTML);
}
,false);
}
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.
http://www.greasespot.net/
精彩评论