Solution 1 :

You’re not specific about what you mean by “changed”, because my answer could be different based on that but this covers (almost) any change.

With outerHTML:

var a = document.getElementById("elementID").outerHTML;
setInterval(function() {
    // checks the stored text against the current
    if (a !== document.getElementById("elementID").outerHTML) { 
        alert("There has been a new message.");
        // do your stuff
    // updates the global var to store the current text
    a = document.getElementById("elementID").outerHTML; 
}, 150); //define your interval time, every 0.15 seconds in this case

Problem :

Is it possible to set a callback that will be called when the innerHTML member of an HTML element is changed? For example, of the document or body?
Thanks in advance!