Just use the onload
event for iframe
.
See an example:
window.addEventListener('load', function(){
var iframe = document.querySelector('iframe'),
carregar = document.querySelector('#carregar');
carregar.addEventListener('click', function()
{
// mudamos o src do iframe
iframe.src = 'include.php?' + new Date()
});
iframe.addEventListener('load', function(){
alert('carregou o conteúdo do iframe')
})
})
HTML:
<iframe></iframe>
<a href="#" id="carregar">Carregar</a>
I made the example by changing the src
of the iframe
later through the click event in #carregar
so that it can be more noticeable at the time of testing.