JS Iframe loader

2019-02-19 06:22发布

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.

1条回答
老娘就宠你
2楼-- · 2019-02-19 07:06
<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()});
查看更多
登录 后发表回答