setTimeout()
関数呼び出しの実行後にページを更新する方法はありますか?
setTimeout関数呼び出しのコードは次のとおりです。
setTimeout(function(){
$('#alert-success').slideUp('slow').fadeOut();
}, 5000);
setTimeout()
関数呼び出しの実行後にページを更新する方法はありますか?
setTimeout関数呼び出しのコードは次のとおりです。
setTimeout(function(){
$('#alert-success').slideUp('slow').fadeOut();
}, 5000);
で試してみてください
setTimeout(function(){
$('#alert-success').slideUp('slow').fadeOut(function() {
window.location.reload();
/* or window.location = window.location.href; */
});
}, 5000);
あなたはこのようにすることができます:(あなたが使うとき、使う.slideUp
必要はありません.fadeOut
)
setTimeout(function() {
$('#alert-success').slideUp('slow', window.location.reload);
}, 5000);
以下でこれを試してください
<html>
<head>
<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}
// -->
</script>
</head>
<body onload="JavaScript:timedRefresh(5000);">
<p>This page will refresh every 5 seconds. This is because we're using the 'onload' event to call our function. We are passing in the value '5000', which equals 5 seconds.</p>
<p>But hey, try not to annoy your users too much with unnecessary page refreshes every few seconds!</p>
</body>
</html>
使用することもできます
window.location.href = window.location.href
スクリプトは次のように書き直されました
setTimeout(function()
{
$('#alert-success').slideUp('slow').fadeOut();
window.location.href = window.location.href
},5000)