Javascript Miscellanea-display data Real time, using window.status_ typical effects
Source: Internet
Author: User
<script type= "Text/javascript" >
<! [cdata[
function Fstatus () {
for (var i=0; i<100000; i++) {
Window.status = "Now process is \" "+i+" \ "";
}
}
function finnerhtml () {
for (var i=0; i<1000; i++) {
document.getElementById ("Demo"). InnerHTML = "Now process is \" "+i+" \ ";
}
}
]]>
</script>
<input type= "button" onclick= "Fstatus ()" value= "Test Status"/>
<input type= "button" onclick= "finnerhtml ()" value= "Test InnerHTML"/>
<div id= "Demo" ></div>
In the above example,one have a-loop and display it real time use InnerHTML property, another are use Window.status.
However, the window.status in real time this perfect display the loop digit, but the InnerHTML property isn't.
Just Display result Digit:now The process is "999".
And how to using InnerHTML display real time data? Can but use window.settimeout, or Window.setinterval method, like this:
var cnt=0;
function finnerhtml () {
if (cnt++>=1000) return;
document.getElementById ("Demo"). innertext = "Now process is \" "+cnt+" \ ";
Window.settimeout (finnerhtml,10)
}
But, it ' s no convenient. The display speed is not, and we must control something.
e.g.
settimeout variables, when it completely.
So, I propose winodw.status to replace the InnerHTML property as display in real time.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.