user893664
user893664

Reputation: 319

javascript code to make sure if an iframe has loaded completely

I want to retrieve content of a web page loaded in iframe- I understood (from other Q&As on Stack Overflow) that this can be done using the following code :

document.getElementById('iframeId').contentWindow.document.body.innerHTML

Please clarify the following for me :

It should be ensured that the iframe has completely loaded, before running the above command.

How do I ensure this? (In javascript or java/jsp)

Upvotes: 0

Views: 439

Answers (1)

Teddy
Teddy

Reputation: 18572

If you are using jQuery, you can do something like this:

jQuery("div#iframe_holder > iframe").load(function() {
  // do something when iframe is done loading 
});

Upvotes: 1

Related Questions