用JS咯
你这个需求显然不是5S让页刷新一次,而是提交一次吧?
var time;
    var second
    function refreshOnTime()
    {
        if(time==null)
            time=document.getElementById("txtRefreshTime").value;
        if(second==null)
            second=parseInt(time);
        second=second-1;
        if(second==0)
        {
            //document.getElementById("txtRefreshTime").value=time;
            second=time;
            document.getElementById("btnRefresh").click();
        }
    }
window.setInterval(refreshOnTime,1000)
可以让time等于5,在页面放一个隐藏的button,点击button即保存你的数据。5秒让这个button点一次:
document.getElementById("btnRefresh").click();

解决方案 »

  1.   

    对对
    非常感谢您!~
    这个隐藏的button要怎么写呢?
    刚开始弄,不太会,请给个例子吧,谢谢
      

  2.   

    就放个普通的button啊,然后让他的style="display:none"
    就隐藏了。
    具体点button执行的服务端代码你自己写就OK了。
      

  3.   

    也可以不用button的。在js中 document.main.target = "";
    document.main.action = "save.jsp";
    document.main.submit();
      

  4.   

    javascript里面有个时间函数
    好像是:setInterval
        function f_pageload()
        {
           window.location.reload();
        }
        window.setInterval(f_pageload,1000);
    写的比较简单,嘿嘿!
      

  5.   

    最直观的方法时间控件
     <asp:Timer ID="Timer1" runat="server"  Interval="5000" OnTick="Timer1_Tick"></asp:Timer>
    在Timer1_Tick时间里面让它刷新
      

  6.   

    综合楼上大家的意见,先写了个例子给你看一下:
    test.asp<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head><body>
    <form action="test.asp" name="main">
    <textarea name="test"><%=Request("test")%></textarea>
    </form>
    <div><%=Request("test")%></div>
    </html>
    <script>
    function Input(){
        document.main.submit();
    }
    window.setInterval(Input,1000); 
    </script>该例相对简单易懂,但用户体验极差,提交时用户被强迫中断操作!我写了一个后台无刷新提交的例子,请看下一回复!
      

  7.   


    test.asp
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <%
    If Request("act")="ajax" Then
    Response.Expires=-1
    Response.Write(Request("info"))
    Response.End()
    End If
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript">
    var xmlHttp
    function GetXmlHttpObject()
    {
      var xmlHttp=null;
      try
        {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
        }
      catch (e)
        {
        // Internet Explorer
        try
          {
          xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
          }
        catch (e)
          {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
          }
        }
    return xmlHttp;
    }
    function Input()
    {
    var objHTML = document.getElementById("showit").innerHTML;
    objHTML = "正在获取数据,请稍候……";
    xmlHttp =GetXmlHttpObject();
    //var xmlHttp = main.xmlHttp;
    if (xmlHttp==null){objHTML="您的浏览器不支持本站程序,请改用其他浏览器!";return;}
    var url="test.asp";
    url+="?act=ajax&info="+document.getElementById("text").value;
    xmlHttp.onreadystatechange=ChangeCont;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    }
     
    function ChangeCont()
    {
        if(xmlHttp.readyState==4)
        {
            document.getElementById("showit").innerHTML=xmlHttp.responseText;
        }
    }
    window.setInterval("Input()",1000); 
    </script>
    </head><body>
    <form id="main" action="test.asp" method="get">
    <textarea id="text"></textarea>
    </form>
    <div id="showit"></div>
    </html>采用ajax方式,用户无感!