Page auto-refresh and javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lew

    Page auto-refresh and javascript

    Hi all,

    I'm trying to create a page that has a user-selectable page auto-refresh
    option (IE 5.5). Essentially, it's a page that contains a checkbox, when
    the user checks the checkbox, I'd like the page to auto-refresh every 4
    seconds....if the user un-checks the checkbox, I'd like to turn off the auto
    refresh.

    The page is as follows:

    <HTML>
    <HEAD>

    <%

    String action = request.getPara meter("chkRefre sh");
    String refreshCmd = "";

    if (action != null) {
    refreshCmd = "setInterval('w indow.location. reload()', 4000);";
    } else {
    refreshCmd = " ";
    action = "off";
    }

    %>

    <SCRIPT LANGUAGE="JavaS cript"><!--

    <%=refreshCmd %>

    function setAutoRefresh( ) {
    data.submit();
    }

    //-->
    </SCRIPT>

    <TITLE>test.jsp </TITLE>
    </HEAD>
    <BODY>
    <FORM NAME="data" ACTION="test.js p" METHOD="post">

    <% if (action.equalsI gnoreCase("off" )) { %>
    <P><INPUT type="checkbox" name="chkRefres h"
    onclick="setAut oRefresh()">Aut o Refresh OFF</P>
    <%} else {%>
    <P><INPUT type="checkbox" name="chkRefres h" onclick="setAut oRefresh()"
    checked>Auto Refresh ON</P>
    <% } %>

    </FORM>
    </BODY>
    </HTML>


    This works in that it turns the auto-refresh on when the user checks the
    "Auto Refresh" checkbox...howe ver, I keep getting the following pop-up
    message:

    "The page cannot be refreshed without resending the information. Click Retry
    to send the information again, or click Cancel to return to the page that
    you were trying to view"

    Is there anyway to avoid the above pop-up?

    Thanks in advance.


  • jon

    #2
    Re: Page auto-refresh and javascript

    Hi,

    It the form method "post" that is causing that message to appear. If
    you set it to "get", or do not define it, then that message will not
    appear.

    <FORM NAME="data" ACTION="test.js p" METHOD="get">

    or

    <FORM NAME="data" ACTION="test.js p">

    The trade off is that the "chkRefresh " field will now be appended to
    the url.

    best,


    jon



    Comment

    Working...