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,450
  • 15
  • 68
  • 141
Jonas Hansen
  • 55
  • 1
  • 9

2 Answers2

0

Try with "on load" like

$('#my_iframe').on('load', function(){
    $(this).show(); 
 });
GautamD31
  • 28,552
  • 10
  • 64
  • 85
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,536
  • 1
  • 20
  • 27