【发布时间】:2016-05-25 09:59:30
【问题描述】:
我遇到了一个问题,我正在使用我的网站
<script type="text/javascript">
window.onload = function() {
var countdownElement = document.getElementById('countdown'),
downloadButton = document.getElementById('new_download'),
seconds = 10 ,
second = 0,
interval;
downloadButton.style.display = 'none';
interval = setInterval(function() {
if (second >= seconds) {
downloadButton.style.display = 'block';
countdownElement.style.display = 'none';
clearInterval(interval);
}
second++;
}, 1000);
}
</script>
但是一些谷歌广告一直在加载,这个功能不起作用。所以我想在页面页脚使用这个脚本在 10 秒后停止页面加载
<script type="text/javascript">
setTimeout( function(){
window.stop()
} , 10000 );
</script>
但这不起作用,有什么方法可以在一段时间后停止页面加载或从页面加载时间或其他方法跳过谷歌广告加载时间,window.onload 函数除外
【问题讨论】:
-
...您的网站上有 Google 广告...您想屏蔽?
-
您可能会因为该脚本的数据连接速度慢而毁掉用户......
-
@MadaraUchiha 不,我希望他们在 10 秒后停止加载……一些广告永远加载。
-
相关:Stopping a iframe from loading a page using javascript。第二个答案演示了将 window.stop() 与 setTimeout() 结合使用。
标签: javascript