。
let loadingpercent = percent();
function LoadProj()
{
document.write("Hold On, your request is loading.<br> " loadingpercent)。
}
function percent()
{
//Code Goes here
return NaN;
}
< input type="button" onClick="LoadProj()" value="LoadMe">
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" class="snippet-box-edit snippet-box-result" frameborder="0"></iframe>
uj5u.com熱心網友回復:
你可以在一個變數中存盤百分比,在另一個變數中存盤進度遞增的間隔(以ms為單位)。
然后,在你的LoadProj函式中,增加百分比并將主體的innerHTML設定為正確的值。檢查百分比是否不是100。如果不是,我們可以使用setTimeout來再次呼叫LoadProj,并有一個延遲,在我們的例子中,loadInterval。
var percent = 0;
var loadInterval = 100;
function LoadProj() {
percent 。
document.body.innerHTML = Hold On, your request is loading. " %。
if ( percent != 100) {
setTimeout(LoadProj, loadInterval)
}else{
//Finished loading! 你的代碼在這里...
console.log('完成加載!')
}
< input type="button" onClick="LoadProj()" value="LoadMe">
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" class="snippet-box-edit snippet-box-result" frameborder="0"></iframe>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/321047.html
標籤:
上一篇:如何存盤Firebase認證會話
