locked
Auto Refresh RRS feed

  • Question

  • Hello

    I am usign following code to auto refresh the page fill auto refresh check box is checked.

    <

     

    script type="text/JavaScript">

    <!--

     

    f

     

     

     

    function

     

    function

    function

     

    timedRefresh(id,timeoutPeriod) {

     

    var elm = document.getElementById(id);

     

    if(elm.checked)

     

     

    setTimeout("location.reload(true);", timeoutPeriod);

     

    }

    // -->

    </

     

    script>

    I am calling this from here

     

    <input id="chkAutoRefresh" type="checkbox" checked OnClick="timedRefresh(this.id,5000)"/>

    Its not  refreshing!!

    :(


    Many Thanks Deepak
    Tuesday, April 20, 2010 11:01 AM

Answers

  • Hi Deepak,

    The reason that you page does not refresh is due to the way you are passing the id of the object to the javascript function.  Have a look at this example that illustrates your purpose,

     

    <html>
    <head>
    <script type="text/JavaScript">

    function timedRefresh(id,timeoutPeriod) {
    alert(id);
    var elm = document.getElementById(id);
    if(elm.checked)
    {
    setTimeout("location.reload(true);", timeoutPeriod);
    }
    }

    </script>
    </head>

    <body onload="alert('body loaded');">
    Check to Refresh Page in 5s : <input id="chkAutoRefresh" type="checkbox" OnClick="timedRefresh('chkAutoRefresh', 5000)"/>
    </body>
    </html>

     

    Hope this helps you.

    Best Regards,
    Praneeth


    Praneeth Wickramasinghe (SCJP, SCWCD)
    • Marked as answer by Harry Zhu Tuesday, April 27, 2010 5:21 AM
    Tuesday, April 20, 2010 12:50 PM

All replies

  • Hi Deepak,

    The reason that you page does not refresh is due to the way you are passing the id of the object to the javascript function.  Have a look at this example that illustrates your purpose,

     

    <html>
    <head>
    <script type="text/JavaScript">

    function timedRefresh(id,timeoutPeriod) {
    alert(id);
    var elm = document.getElementById(id);
    if(elm.checked)
    {
    setTimeout("location.reload(true);", timeoutPeriod);
    }
    }

    </script>
    </head>

    <body onload="alert('body loaded');">
    Check to Refresh Page in 5s : <input id="chkAutoRefresh" type="checkbox" OnClick="timedRefresh('chkAutoRefresh', 5000)"/>
    </body>
    </html>

     

    Hope this helps you.

    Best Regards,
    Praneeth


    Praneeth Wickramasinghe (SCJP, SCWCD)
    • Marked as answer by Harry Zhu Tuesday, April 27, 2010 5:21 AM
    Tuesday, April 20, 2010 12:50 PM
  • Hi,

    For the
    questions relating to asp.net ,please post to: http://forums.asp.net/.

    Thanks,
    Harry


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, April 27, 2010 5:21 AM