Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Kill after x number of refreshes?? 3

Status
Not open for further replies.

bzss7x

MIS
Mar 14, 2001
17
US
I have a problem...

First requirement - I need a page to refresh every minute. OK, simple enough I can use the <META> tag for that. Second requirement - I need the page to kill itself after 20 minutes. I'm running a JS loaded by a BODY onload statement that will kill the page after 20 minutes - but wait - if I make the page refresh every minute, it restarts the counter every time. Effectively, it's as if my JS script is not running.

Can anyone think of another way to accomplish this?

 
If you are reloading every minute, then the application should halt after twenty reloads right? Use an incrementing counter as a variable in the refresh tag and when that variable reaches 20 then just response.end before anything is sent to the browser (or don't put the refresh tag in).
 
Maybe I'm not following you or I wasn't clear...

My code...

<HTML>
<!--#include file="kill_screen_inc.asp" -->
<HEAD><TITLE></TITLE>

<META HTTP-EQUIV="Refresh" CONTENT="60">

<BODY onload="KillMe();self.focus()">

yada yada yada


After 60 seconds the page refreshes and again loads the KillMe() function, which starts its internal counter over. Is there another way to call this function?
 
What does KillMe do? If all you want it to do is stop the refresh process then you can use something like this...

Code:
<%
refreshcount = request.querystring("refreshcount")
%>
<HTML>
<HEAD><TITLE></TITLE>
<%
if refreshcount <> 20 then
refreshcount = refreshcount + 1
response.write("<META HTTP-EQUIV='Refresh' CONTENT='60;url=?refreshcount=" & refreshcount & "'>")
end if
%>
<BODY onload="self.focus()">
 
Client side script or server side script?
As client side this will likely not work unless you set a cookie with a counter in it for the refreshes as variables will be reset on reload.

Server side you should append a querystring variable to the url like:

mypage.asp?counter=0
mypage.asp?counter=1

also will work for jsp and php, really any type of server side script. (Note: this is how a get request looks like from the get method in forms). Just access using querystring or your language equivalent.

Then using the server side script logic you will not print anything out on the 20th count or print out javascript instructing the window to close.
 
Thanks guys, you've given me some good ideas...

I try these tomorrow and report back.
 
Excellent suggestions! Because of these, I was able to get it to work!!!

What I ended up doing was a combination of the ideas above.

<%
refreshcount = Request("refreshcount")
if refreshcount = 20 then
response.write("<BODY onload='KillMe();self.focus();'>")
else
refreshcount = refreshcount + 1
response.write("<META HTTP-EQUIV='Refresh' CONTENT='60;URL=http:thissamepage.asp?refreshcount=" & refreshcount & "'>")
'response.write("<BODY>")
end if
%>

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top