刷新HTML网站(显示进度),而javascript不断添加新结果 [英] refresh HTML site (show progress) while javascript continually adds new results

查看:74
本文介绍了刷新HTML网站(显示进度),而javascript不断添加新结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用javascript递归扫描文件系统以进行用户定义的搜索.到目前为止一切正常.在脚本到达搜索末尾之前,仅显示完整的结果.对于大型文件系统,这可能需要一些时间.

如何立即显示连续输出到HTML页面(即result.innerHTML = found),以便用户可以跟踪进度.到目前为止,我仅发现提示"或警报"会导致脚本暂停,从而使窗口更新其中间内容.
必须有一种优雅的方法来避免用户交互!
欢迎任何想法,谢谢

I use javascript to scan the file system recursively for user defined search. All works fine so far. Only the complete results are not displayed before the script reaches the end of its search. With large file systems that can take some time.

How can I perform a continually output into the HTML page (i.e result.innerHTML=found) with an immediate display so that the user can follow the progression. Until now I have only found out that a "prompt" or "alert" causes the script to pause and thus the window to update its intermediate contents.
There must be an elegant method to avoid user interaction!
Any ideas welcomed, thanks

推荐答案



我尝试了一些代码试试这个...

如果它正确给出完整的要求,我可以对其进行修改以满足您的要求.

Hi,

I tried some code try this...

If it correct give complete requirement I can modify it to achieve your requirement.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script language="javascript" >
        var i = 0;
        var tmp;
        function strt() {
            i = parseInt(i) + 1;
            tmp = setInterval("strt()", 1000);
            if (parseInt(i) == 10 || parseInt(i) == 30 || parseInt(i) == 50 || parseInt(i) == 80 || parseInt(i) == 100) {
                document.getElementById("resdiv").innerHTML =i+ "% of process done";
            }
        }
        function stp() {
            clearInterval(tmp);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type ="button" value ="start process" onclick ="strt()" /><br />
        <input type ="button" value ="stop process" onclick ="stp()" /><br />
        <div id="resdiv"></div>
    </div>
    </form>
</body>
</html>



最好的



All the Best


这篇关于刷新HTML网站(显示进度),而javascript不断添加新结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆