0

I have a problem. I can't figure out how I can load an iframe with jQuery or Ajax, and when the content is loaded inside the iframe, then output it to the page.

The problem is that, I am loading an external page on my web site, and sometimes the external page is very slow or does not load. If that happens I don't want the browser to keep trying to load the iframe on my web site, and I don't want a big blank space.

So I need to load an external page in a iframe, without the browser loads and first when or if the content is loaded, then the iframe is showed on the website. Is this possible?

Funk Forty Niner
  • 74,372
  • 15
  • 66
  • 132
Jonas Hansen
  • 55
  • 1
  • 8

2 Answers2

0

Try with "on load" like

$('#my_iframe').on('load', function(){
    $(this).show(); 
 });
Gautam3164
  • 28,027
  • 10
  • 58
  • 83
0

put the iframe in the page:

<div id="theIframeContainer" style="display:none">
  <iframe src="theSite"></iframe>
<div>

then, jquery code

$(function() {
  $("#theIframeContainer").show();
}
Eduard
  • 3,308
  • 1
  • 18
  • 25