I need to listen changes inside iframe tag. The main page doesn't change, only iframe contents.
Iframe pages have form, when some buttons type submit are clicked the form call the action and change the page only inside the iframe.
I probe next, but only works with document main page, only main page document listen for DOM changes, but not inside iframe.
function listener()
{
console.debug("listener fired.");
}
document.addEventListener('DOMSubtreeModified', function() {
var iframes = document.getElementsByTagName("iframe");
for (var i = 0, len = iframes.length, doc; i < len; ++i) {
// Catch and ignore errors caused by iframes from other domains
console.log(i);
try {
doc = iframes[i].contentDocument || iframes[i].contentWindow.document;
//console.log(doc);
doc.addEventListener("DOMSubtreeModified", listener, true);
} catch (ex) { console.log(ex); }
}
},false);