Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
607 views
in Technique[技术] by (71.8m points)

javascript - auto refresh for every 5 mins

this is my code

<html>
<head>
    <script language="javascript" src="JS/jQuery.js"></script>
    <script>
        function page_refresh(){
            document.getElementById('form2').action="project_file_dir.cfm"  
            document.getElementById('form2').submit();          
        }

    </script>
</head>
<body >
<cfoutput>
<cfset fileLocation ="\squeakerSiSystemsFileWebServicesWebSitesPerforceBhargavi"> <!--- On mac set to /tmp --->
<cfdirectory
        action = "list"
        directory = "#fileLocation#"
        name = "files"
        filter="*.*">
<form  method="post" id="form2">
    <cfset f="#files.recordcount#">  
    <cfset mydatetime=now()>
    <cfset a=TimeFormat(MyDateTime,'hh:mm:ss tt')>
      Total File in <b> #fileLocation# </b> Count is <b> #f# </b> #TimeFormat(MyDateTime,'hh:mm tt')#
       <input type="button" name="Refresh" value="refresh" onclick="page_refresh()"><br>
       <b>Next Run</b>
      <cfset b=TimeFormat(DateAdd('n', +5, MyDateTime),'hh:mm:ss tt')>
       #TimeFormat(DateAdd('n', +5, MyDateTime),'hh:mm tt')#
    </cfoutput>

<cfset a= Minute(Now())>
<cfset b=a%5 >  
<cfoutput>#b#</cfoutput>
<!--- <cfinclude template="page_move_2.cfm"> --->
<cfloop condition="b gt 0">
        <cfoutput>inside loop</cfoutput>
    <cfset Sleep(6000)>

    <cfset b = b - 1 >

</cfloop>
<cfoutput>hi</cfoutput>
</form>
</body>
</html>

i need to refresh the page for every 5 mins . how to do this . i used sleep() function but ui itself loaded after that sleep() is executed . this me how to reload the page for every 5 mins

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Refresh document every 300 seconds using HTML Meta tag add this inside the head tag of the page

 <meta http-equiv="refresh" content="300">

Using Script:

            setInterval(function() {
                  window.location.reload();
                }, 300000); 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...