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

Javascript
Web层改进II-用xmlhttp 无声息提交复杂表单
用ADODB.Stream转换
html读出文本文件内容
自适应高度框架 ----属个人收藏内容
Maps Javascript
JAVASCRIPT HashTable
一页面多XMLHttpRequest对象
网页javascript精华代码集
判断浏览器的js代码
JS判断浏览器之Navigator对象
用js自动判断浏览器分辨率的代码
用JavaScript和注册表脚本实现右键收藏Web页选中文本
判断页面是关闭还是刷新的js代码
WebGame《逆转裁判》完整版 代码下载(1月24日更新)
叠加计算出错的解决方法
一个轻量级的XHTML右键菜单[支持IE和firefox]
一些易混淆且不常用的属性,希望有用
网易首页的新闻代码
Flash对联广告的关闭按钮讨论
用JS获得表格当前行数的代码

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 61 ::
收藏到网摘: 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.