开发者

HTML elements hooks in firefox add-ons api

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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜