Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
93
rated 0 times [  96] [ 3]  / answers: 1 / hits: 20263  / 13 Years ago, mon, february 27, 2012, 12:00:00

This is my code :



​<div id=myContent​​​​​​​></div>​

$('#myContent').html('<iframe height=200 frameborder=0 src=www.google.com></iframe>');​


and I'd like, when the whole page in the frame is totally loaded, call a function, like alert(I'm finished);.



How can I do it?



P.S. dunno why jsfiddle doesnt catch the google page :)


More From » jquery

 Answers
21

You can do it with the event .load() (Check the api for more info).



Example:



$('#myContent').html('<iframe id=winId height=200 frameborder=0 src=www.google.com></iframe>');

$('#winId').load(function() {alert('loaded')})

[#87184] Saturday, February 25, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brandt

Total Points: 43
Total Questions: 90
Total Answers: 111

Location: Aruba
Member since Fri, Jun 24, 2022
2 Years ago
;