I have an iframe with an independent page displayed inside. What i need is an eventhandler on the outer page to be executed when somehow the location/url inside the iframe is changed (like when clicking a link on the inner page that leads to another page, which is then displayed again inside the frame). It should fire when the new DOM is loaded.
Currently I use jQuery's load()
function according to this stack overflow question
$("#iframe").load(function(){console.log("iframe loaded");})
This works well but it fires only when the content is completely loaded, including images etc. What I am looking for is a handler that fires when only the DOM is ready (without images), like the ready()
function. I already tried
var iframe = document.getElementById('frame'),
iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
$(iframeDoc).ready(function(){console.log("iframe loaded");}
but it did not work.
Does somebody have an idea?