[英]Passing page loading time in progress bar
我的頁面上有進度欄。 它應該顯示直到頁面完全加載。 所以我希望進度條顯示在頁面上等於頁面加載時間。 因此,我嘗試獲取頁面加載時間並將該時間值傳遞給進度條。 我已經完成編碼
<script type="text/javascript">
var startTime = new Date().getTime();
var loadTime;
function pageload() {
var endTime = new Date().getTime();
loadTime = endTime - startTime;
// alert(loadTime);
}
window.onload = function () { pageload(); }
jQuery(document).ready(function () {
jQuery('#container').showLoading(
{
'afterShow':
function () {
var a = loadTime;
setTimeout("jQuery('#container').hideLoading()", a);
}
});
});
</script>
之后,此更改有效!
<script type="text/javascript">
var startTime = new Date().getTime();
var loadTime;
function pageload() {
var endTime = new Date().getTime();
loadTime = endTime - startTime;
setTimeout("jQuery('#container').hideLoading()", loadTime);
// alert(loadTime);
}
window.onload = function () { pageload(); }
jQuery(document).ready(function () {
jQuery('#container').showLoading();
});
</script>
我可能是錯的,但我認為您只想將其隱藏在onLoad
,如下所示:
jQuery(document).onload(function(){
jQuery('#container').hideLoading();
});
或將其放在您的pageload()
函數中:
function pageload() {
var endTime = new Date().getTime();
loadTime = endTime - startTime;
jQuery('#container').hideLoading();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.