About loading Jquery page

1

I understand the use of this code snippet in Jquery below:

$(document).ready(function() { 
alert("carregou");
})

However, the problem in question is that when I load something into an iframe, this function does not run again, how do I detect when an iframe is loaded?

Initially, when entering the page, the iframe is not displayed, the above function complies, alerting when the html page is loaded, but the person can choose between the screen options, and so will open an iframe in any option chosen, but does not display the message "loaded" when the iframe finishes loading. Anyway, the question is:

How do I detect when an iframe is loaded?

    
asked by anonymous 27.10.2014 / 15:33

1 answer

2

Your JavaScript function is implemented to run once the document (the page, so to speak) is loaded.

For the function to run after an iframe is loaded, use:

$(document).ready(function() {
    $('iframe').ready(function() {
        alert("carregou iframe");
    });
})
    
27.10.2014 / 15:38