Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need web page refresh for every 60sec and redirect to another page on without operation on page. If am doing any operation on page not refreshed and not redirected to another page.

For example take 3 webpages.
There is no opeartion on page 1 for 60 sec automatically redirect to page2.
There is no opeartion on page 2 for 60 sec automatically redirect to page3,
If there is doing any operation not redirect to another webpage.

How to write in client side using javascript ?

If any one know about this Reply me.

Regards
Nanda Kishore.CH
Posted
Updated 13-Oct-12 1:20am
v4
Comments
[no name] 13-Oct-12 5:00am    
You mean something like screen saver?
nandkishorre 13-Oct-12 5:11am    
No. I am using meta tag in client side its refresh automatically. if am doing opertion on that screen after finish the meta tag time its automatically redirect to another page. but here doing opertion not redirect to another page.
n.podbielski 13-Oct-12 7:16am    
First you downvoted my solution with JS without reason, and the you editing your question to give you solution with JS code?
Thanks!

You can set JS timeOut:
JavaScript
var timeout = setTimeout(callback);


Problem is what you consider an 'operation'. Click? Key press?
You can attach callback for every event you want:


JavaScript
$().click(function(){
clearTimeout(timeout);
});


If you using DevExpress you can use ASPxTimer control.
 
Share this answer
 
You can also use meta tag for refreshing as shown below.

C#
<meta id="refreshRate" runat="server" http-equiv="refresh" content=""/>


Now that we have given id to this meta-tag, you can access in code-behind and set or reset.

refreshRate.Content = "2";


Here 2 is seconds interval

-Milind
 
Share this answer
 
just use ajax timer....with condition timer_tick()..assign the timeperiod and redirect it to required page..
 
Share this answer
 
Hi, Please try this code. It is tested & working fine

XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script language="javascript" type="text/javascript">
        var c = 0;
        var t;
        function startexpiry() {
            document.getElementById("txtIdleTime").value = c;
            c = c + 1;
            t = setTimeout(function () { startexpiry() }, 1000);
            if (c == 60) {
                clearTimeout(t);
                window.location = "http://www.google.com";
            }
        }

        function start() {
            c = 0;
           if(t!=null) clearTimeout(t);
            startexpiry();
        }

    </script>
</head>
<body>
    <form id="form1"  runat="server"  onmouseenter ="start()" onclick ="start()" onkeypress="start()">
    <div>
    You are idle for Seconds.. <input id="txtIdleTime" type="text" /> <br />

    <br />Name <input id="txtName" type="text" />
    <br />Email <input id="txtAddress" type="text" />
    <br />Name <select id="ddlState">
    <option>State 1</option>
    <option>State 2</option>
    </select>
    </div>
    </form>
</body>
<script language="javascript">
    start();
</script>
</html>
 
Share this answer
 
This will Help You

XML
<html>
<head>
<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
    setTimeout("location.reload(true);",timeoutPeriod);
}
//   -->
</script>
</head>
<body onload="JavaScript:timedRefresh(5000);">
<p>This page will refresh every 5 seconds. This is because we're using the 'onload' event to call our function. We are passing in the value '5000', which equals 5 seconds.</p>
<p>But hey, try not to annoy your users too much with unnecessary page refreshes every few seconds!</p>
</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