当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Javascript miscellanea -display data real time, using window.status

Javascript
[IE&FireFox兼容]JS对select操作
JS实现全景图效果360度旋转
Unicode 编码转换器
如何用javascript判断录入的日期是否合法
图片从右至左滚动JS
JS控件autocomplete 0.11演示及下载 1月5日已更新
一个对于js this关键字的问题
Javascript标准DOM Range操作全集
兼容Mozilla必须知道的知识。
你所要知道JS(DHTML)中的一些技巧
JS效率个人经验谈(8-15更新),加入range技巧
如何让动态插入的javascript脚本代码跑起来。
Javascript调试工具(下载)
脚本中出现 window.open() access is denied - 拒绝访问 情况一则及分析
Javascript-Mozilla和IE中的一个函数直接量的问题
贴一个在Mozilla中常用的Javascript代码
Javascript miscellanea -display data real time, using window.status
js技巧--转义符"\"的妙用
In Javascript Class, how to call the prototype method.(three method)
Javascript与vbscript数据共享

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 35 ::
收藏到网摘: n/a

<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 is use window.status.
However, the window.status in real time that perfect display the loop digit, but the innerHTML property is not.
Just display result digit: now 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 well, and we must control something.
e.g.
setTimeout variables, when it completely.
So, I propose winodw.status to replace innerHTML property when display in real time.