About page loading Jquery

Asked

Viewed 66 times

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 by iframe, this function is not run again, how do I detect when an iframe is loaded?

Initially, when entering the page, the iframe is not displayed, the function above meets, warning when the html page is loaded, but the person can choose between the options of the screen, and so will open an iframe in any option chosen, but it is not displayed the message "loaded" when iframe finishes loading.. Anyway, the point is:

how do I detect when an iframe is loaded?

1 answer

2

Your Javascript function is implemented to be executed once the document (the page, so to speak) is loaded.

To run the function after an iframe is loaded, use:

$(document).ready(function() {
    $('iframe').ready(function() {
        alert("carregou iframe");
    });
})
  • Perfect, it worked right here, I just switched the ready for load, so that the page is actually expected to load all the features beyond the said rendering.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.