2012-08-29 47 views

回答

21

嘗試

setTimeout(function(){ 
    $('#alert-success').slideUp('slow').fadeOut(function() { 
     window.location.reload(); 
     /* or window.location = window.location.href; */ 
    }); 
}, 5000); 
+0

在編,但你打我:) – Flash

+0

由於一噸快速響應,法布里奇奧現在就解決了。 – Arish

2

你可以這樣做: (當你使用.slideUp,就沒有必要使用.fadeOut

setTimeout(function() { 
    $('#alert-success').slideUp('slow', window.location.reload); 
}, 5000); 
+0

謝謝xdazz會記住它。 – Arish

1

下面試試

<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> 
+0

感謝您的回覆,我已經找到了Fabrizio的解決方案:) – Arish

1

您還可以使用

window.location.href = window.location.href 

劇本改寫爲

setTimeout(function() 
{ 

    $('#alert-success').slideUp('slow').fadeOut(); 
    window.location.href = window.location.href 

},5000)