468,249 Members | 1,499 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

Page auto-refresh and javascript

Lew
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.getParameter("chkRefresh");
String refreshCmd = "";

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

%>

<SCRIPT LANGUAGE="JavaScript"><!--

<%=refreshCmd %>

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

//-->
</SCRIPT>

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

<% if (action.equalsIgnoreCase("off")) { %>
<P><INPUT type="checkbox" name="chkRefresh"
onclick="setAutoRefresh()">Auto Refresh OFF</P>
<%} else {%>
<P><INPUT type="checkbox" name="chkRefresh" onclick="setAutoRefresh()"
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...however, 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.
Jul 20 '05 #1
1 33910
jon
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.jsp" METHOD="get">

or

<FORM NAME="data" ACTION="test.jsp">

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

best,
jon

http://www.gurupika.com/
http://forums.gurupika.com/
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Howard Martin | last post: by
7 posts views Thread by Brian Paul | last post: by
2 posts views Thread by tradmusic.com | last post: by
16 posts views Thread by matt | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.