Just use the event onload
to the iframe
.
Take 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 iframe
through the click event #carregar
so that it can become more noticeable at the time of testing.