admin管理员组文章数量:1357302
I want to reload window after a this custom function finishes:
<script type="text/javascript">
$(document).ready(function(){
setTimeout(function () {
$('#order_form').dolPopupHide({});
}, 3000);
//window.location.reload();
});
</script>
Is there a way I can add the reload to the setTimeout function so it doesn't run until the timeout is over?
I want to reload window after a this custom function finishes:
<script type="text/javascript">
$(document).ready(function(){
setTimeout(function () {
$('#order_form').dolPopupHide({});
}, 3000);
//window.location.reload();
});
</script>
Is there a way I can add the reload to the setTimeout function so it doesn't run until the timeout is over?
Share Improve this question edited Oct 20, 2010 at 14:50 tmartin314 asked Oct 20, 2010 at 14:45 tmartin314tmartin314 4,18110 gold badges42 silver badges60 bronze badges 3-
Did you try
window.location.reload();
? If so, how does that not meet your need? – LarsH Commented Oct 20, 2010 at 14:48 - It reload right away basically. And the page doesn't fully load before it starts. – tmartin314 Commented Oct 20, 2010 at 14:49
- In this context, using document.ready is overkill. setTimeout() already establishes that the code will run later. – jimbo Commented Oct 20, 2010 at 15:28
1 Answer
Reset to default 7reload
needs to be inside your function:
$(document).ready(function(){
setTimeout(function () {
$('#order_form').dolPopupHide({});
window.location.reload();
}, 3000);
});
If you want to conceptually separate the work from the reload, you can do something like this:
$(document).ready(function(){
setTimeout(function () {
doWork();
window.location.reload();
}, 3000);
function doWork() {
$('#order_form').dolPopupHide({});
}
});
Or, to be even more general:
function reloadAfterExec(fn)
return function() {
fn();
window.location.reload();
}
}
$(document).ready(function(){
setTimeout( reloadAfterExec(function() {
$('#order_form').dolPopupHide({});
}), 3000);
});
本文标签: javascriptReload when setTimeout function finishesStack Overflow
版权声明:本文标题:javascript - Reload when setTimeout function finishes - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743975621a2570865.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论