如果用户输入时间,则引用页面,它将使用javascript设置为默认时间 [英] refersh the page if the user enter the time it will be set the default time using javascript

查看:76
本文介绍了如果用户输入时间,则引用页面,它将使用javascript设置为默认时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将创建一个默认情况下每5分钟自动刷新一次的网页.在页面中,提供一个选项供用户输入页面刷新的持续时间.假设用户输入了10分钟.然后页面应每10分钟刷新一次.如果用户输入0,则页面不会刷新.

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.

推荐答案

请参阅以下链接:
自动刷新网页 [ JavaScript刷新代码示例 [
Refer these links:
Auto Refresh Web Page[^]
Example JavaScript Refresh Code[^]

Good luck.


更好地使用Ajax Web表单...
添加一个计时器控件并将其间隔设置为"300000",现在每5分钟刷新一次页面.

您可以添加文本框以输入用户时间偏好设置,并且可以在其文本更改事件上输入以更改计时器intevel属性...

如果您不需要刷新整个页面,请在页面的所需部分使用ajax upade面板...
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...


<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>


这篇关于如果用户输入时间,则引用页面,它将使用javascript设置为默认时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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