Or Weinberger
Or Weinberger

Reputation: 7472

JS Iframe loader

I'm looking for a way to use jQuery/js to show a 'Loading...' message while an iframe is loading, when the iframe finished to load completely, the 'Loading...' text should disappear.

Is that possible with jquery/js?

Note: I do not have any control on the website within the iframe.

Upvotes: 2

Views: 5218

Answers (1)

mplungjan
mplungjan

Reputation: 177885

<script>
function hide() {
  document.getElementById('loading').style.display='none';
}
</script>
<iframe onLoad="hide()" ... ></iframe>
<div id="loading">Please wait</div>

jquery:

$("iframe").load(function() { $("#loading").toggle()});

Upvotes: 8

Related Questions