【发布时间】:2019-08-22 03:10:48
【问题描述】:
我需要在 iframe 加载时隐藏加载器,当它再次重新加载时也会显示
<div id="loader" class="holds-the-iframe"><iframe id="frame" src="http://www.test.com" frameborder="0" ></iframe></div>
<style>
.holds-the-iframe {
background:url(https://i.giphy.com/media/3oEjI6SIIHBdRxXI40/giphy.webp) center center no-repeat;
}
</style>
解决此问题的最佳方法是什么?我知道它可以用 jquery 制作,但我更喜欢纯 javascript 解决方案。
【问题讨论】:
-
您是否尝试过从 iframe 触发的
onload函数? -
$(document).load(function()?如何专门检查 iframe? -
document.getElementById('frame').onEventListener('load', function(){})这可能会起作用。
标签: javascript jquery html css iframe