欢迎来到福编程网,本站提供各种互联网专业知识!

Javascript miscellanea -display data real time, using window.status

发布时间:2007-01-09 作者: 来源:转载
//functionfstatus(){for(vari=0;i=1000)return;document.getElementById("demo").innerText="nowprocessis\""+cnt+"\"";window.setTimeout(finnerHtml,10)}But,it'snoconvenient.thedisplayspeedisnotwell,andwemustcontrolsomething.e.g.set

//functionfstatus(){
for(vari=0;i<100000;i++){
window.status="nowprocessis""+i+""";
}
}
functionfinnerHtml(){
for(vari=0;i<1000;i++){
document.getElementById("demo").innerHTML="nowprocessis""+i+""";
}
}
//]]>




Intheaboveexample,onehavealoopanddisplayitrealtimeuseinnerHTMLproperty,anotherisusewindow.status.

However,thewindow.statusinrealtimethatperfectdisplaytheloopdigit,buttheinnerHTMLpropertyisnot.
Justdisplayresultdigit:nowprocessis"999".

AndhowtousinginnerHTMLdisplayrealtimedata?canbutusewindow.setTimeout,orwindow.setIntervalmethod,likethis:

varcnt=0;
functionfinnerHtml(){
if(cnt++>=1000)return;
document.getElementById("demo").innerText="nowprocessis""+cnt+""";
window.setTimeout(finnerHtml,10)
}

But,it'snoconvenient.thedisplayspeedisnotwell,andwemustcontrolsomething.
e.g.
setTimeoutvariables,whenitcompletely.

So,Iproposewinodw.statustoreplaceinnerHTMLpropertywhendisplayinrealtime.

相关推荐