I’m trying to figure out a way to some how ‘bind an event’ to the innerHTML property. As an example, if I do something like:
<containerElement>.innerHTML='some HTML code';
I would like somehow to be able to fire an event to accommodate the updated container content.
I just spent today and yesterday teaching myself prototypes and literals and all that cool stuff; from what I was able to pick up, I came up with the following unfunctioning (go figure:D ) script:
<script language="javascript" type="text/javascript" src="prototype.js"></script>
<script language="javascript" type="text/javascript">
Object.prototype.initialize = function(){
this.innerHTML.bind(this.update());//I'm imagining you laughing at this line :)
}
Object.prototype.update = function(){
alert('testing');
}
window.onload = function(){
document.getElementById('containerDiv').initialize();//Make object into a container
}
</script>
This is not possible in this form, I’m afraid. In theory, this what “mutation events” like “NodeAdded” etc are for, but they are still not fully supported in major browsers. The practical solution would be to have a timer function watching for the content change.