我想建立一個進度條,在0.1秒的延遲之後完成,隱藏帶有剪輯效果的欄,然後延遲0.2秒後再次加載google.com 。window.location令人煩惱的JQuery代碼
我的代碼:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Progressbar - Custom Label</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<style>
.ui-progressbar {
position: relative;
}
.progress-label {
position: absolute;
left: 50%;
top: 4px;
font-weight: bold;
text-shadow: 1px 1px 0 #fff;
}
</style>
<script>
$(function() {
var progressbar = $("#progressbar"),
progressLabel = $(".progress-label");
progressbar.progressbar({
value: false,
change: function() {
progressLabel.text(progressbar.progressbar("value") + "%");
},
complete: function() {
progressLabel.text("Complete!");
$("#progressbar").delay(100).hide("clip").delay(200);
window.location = "http://www.google.com";
}
});
function progress() {
var val = progressbar.progressbar("value") || 0;
progressbar.progressbar("value", val + 3);
if (val < 99) {
setTimeout(progress, 100);
}
}
setTimeout(progress, 3000);
});
</script>
</head>
<body>
<div id="progressbar"><div class="progress-label">Loading...</div></div>
</body>
</html>
的問題是,即使之前的影響都可能發生,頁面加載http://www.google.com。是否有某種我可以使用的時間延遲?
謝謝。
Thanks.But,我應該把這段代碼放在$(「#progressbar」).delay(100).hide(「clip」)。delay(200)之下嗎? –
感謝您的幫助。 –
@GaurangTandon當您設置超時時,在參數 –