Click here to Skip to main content
15,913,685 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Iam creating a web page which will automatically refresh for every 5 minutes by default. In the page provide an option for the user to enter the time duration in which page should refresh. Say if user enters 10 mins. then page should refresh every 10th minute. If user enters 0 the page should not refresh.
Posted
Updated 12-Aug-12 20:51pm
v4
Comments
__TR__ 13-Aug-12 2:06am    
Please be more specific on what you need. Your question looks like an assignment given to you. If you have tried out something post your code.
Please read the rules for posting a question.
Code Project Quick Answers FAQ[^]
keerthana.k 13-Aug-12 2:19am    
if user enter the time means it will set the default time then page should refresh every time(user specified) but i dont know how to set user time as default time
AshishChaudha 13-Aug-12 2:11am    
So, have you tried anything???
keerthana.k 13-Aug-12 2:15am    
yes


Refer these links:
Auto Refresh Web Page[^]
Example JavaScript Refresh Code[^]

Good luck.
 
Share this answer
 
Comments
keerthana.k 13-Aug-12 2:36am    
i know how to refrsh the page but my questions is if the user enter the time in textbox then how it will be set the default time using javascript
better to use ajax web form...
add a timer control and set its intervel to "300000" now the page will be refreshed in every 5 mintutes...

you can add text box to enter user time preference and its on text changed event to change timer intevel property...

if you do not need to refresh whole page use ajax upade panel for the desired portion of the page...
 
Share this answer
 
Comments
keerthana.k 13-Aug-12 2:33am    
i need javascript only dont use any other lang
XML
<title> Reload  the Page</title>
    <script type="text/javascript">
    function ref1()
    {
    var time=document.getElementById("txttime").value;
    if(time!="" && time!=0)
    {
    time=time*1000;
    setTimeout("location.reload();",time);
    alert("page reload after the 5 seconds");

    }
    else if(time=="")
    {
     time=10000;
     setTimeout("location.reload();",time);
     alert("page reload after the 10 seconds");
    }
    }
    </script>
</head>
<body onload="return ref1()">
    <form id="form1" runat="server">
    <div>
    <table>
    <tr>
    <td>Enter the time:</td><td><input type="text" id="txttime" /></td></tr>
    <tr><td align="center"><input type="button" value="enter" id="bttme" onclick="return ref1()"; /></td></tr></table>
    </div>
    </form>
</body>
</html>
 
Share this answer
 
Comments
AshishChaudha 13-Aug-12 2:21am    
Have you solved your problem?? Is this your solution???. Then mark it as your solution. If not please remove from solution and Click on improve question link.
keerthana.k 13-Aug-12 2:34am    
i tried but i did not get the full answer
XML
<title> Reload  the Page</title>
    <script type="text/javascript">
    function ref1()
    {
    var time=document.getElementById("txttime").value;
    if(time!="" && time!=0)
    {
    time=time*1000;
    setTimeout("location.reload();",time);
    alert("page reload after the 5 seconds");

    }
    else if(time=="")
    {
     time=10000;
     setTimeout("location.reload();",time);
     alert("page reload after the 10 seconds");
    }
    }
    </script>
</head>
<body onload="return ref1()">
    <form id="form1" runat="server">
    <div>
    <table>
    <tr>
    <td>Enter the time:</td><td><input type="text" id="txttime" /></td></tr>
    <tr><td align="center"><input type="button" value="enter" id="bttme" onclick="return ref1()"; /></td></tr></table>
    </div>
    </form>
</body>
</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900