JS Iframe loader

狂风中的少年 提交于 2019-12-19 10:18:38

问题


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:


<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()});


来源:https://stackoverflow.com/questions/5194679/js-iframe-loader

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!