View Full Version : redirect file
vinodh
09-30-2004, 09:53 AM
<!-- Begin
redirTime = "8000";
redirURL = "retrival.asp?agent=<%=agent%>";
function redirTimer() { self.setTimeout("self.location.href = redirURL;",redirTime); }
// End -->
comments : redirect to retrival.asp(file name) every 8 sec.
This is in javascript.
how i am suppose to do that type of command in asp?
rynox
10-01-2004, 06:26 PM
You want an ASP script that will pause 8 seconds and redirect to retrival.asp?agent=<%=agent%>, correct?
Normally with VBScript, you would use the WScript.Sleep method to pause a script, but IIS doesn't give you access to the WScript object. If you were allowed to do this and you did, then the IIS script parser would wait a whole 8 seconds while it is preparing its http RESPONSE. Not sure, but I suspect this would put quite a load on the server.
Rather, a better way would be to pause the user's browser using javascript and after the 8 seconds is up, send them to another script that would redirect them. The code to do this in ASP is:
Response.Redirect "retrival.asp?agent=" & agent
Word of caution...this sends a redirect in the http header. Once IIS encounters the first html tag or javascript, it sends the http header, so this code has to be at the top of your ASP script. If you have it below, you will get an error like "http headers already sent."
BuddhaMan
10-02-2004, 03:46 PM
I found this code on the 'net a while back. It works great when you need a delay in your ASP code for some reason.
'****************************************
' Sub that delays one second per # input
' ie: Delay(5) will delay 5 seconds
'****************************************
Sub Delay(DelaySeconds)
SecCount = 0
Sec2 = 0
While SecCount < DelaySeconds + 1
Sec1 = Second(Time())
If Sec1 <> Sec2 Then
Sec2 = Second(Time())
SecCount = SecCount + 1
End If
Wend
End Sub
glenngv
10-04-2004, 04:38 AM
Why not just use the meta tag?
<%
dim redirTime, redirURL
redirTime = 8 'in seconds
redirURL = "retrival.asp?agent=" & agent
%>
<html>
<head>
<meta http-equiv="refresh" content="<%=redirTime%>; url=<%=redirURL%>" />
</head>
<body>
<p>Please wait...You will be redirected to another page in a moment</p>
<p>If you are not redirected or you cannot wait any longer, please click <a href="<%=redirURL%>">this</a>.</p>
</body>
</html>
ghell
10-04-2004, 08:29 PM
not much to add but.. yea use a meta tag.. its the most simple way.. im pretty sure like 99% of browsers support it too
yet again glenn comes through :thumbsup:
BigDaddy
10-06-2004, 05:28 PM
I found this code on the 'net a while back. It works great when you need a delay in your ASP code for some reason.
'****************************************
' Sub that delays one second per # input
' ie: Delay(5) will delay 5 seconds
'****************************************
Sub Delay(DelaySeconds)
SecCount = 0
Sec2 = 0
While SecCount < DelaySeconds + 1
Sec1 = Second(Time())
If Sec1 <> Sec2 Then
Sec2 = Second(Time())
SecCount = SecCount + 1
End If
Wend
End Sub
Won't that cause the server to lock up on that for a second--thereby causing other things to hang?
Roy Sinclair
10-06-2004, 09:36 PM
Won't that cause the server to lock up on that for a second--thereby causing other things to hang?
Definitely, that's the worst possible way to accomplish a delay since it'll tie up the server with 100% CPU usage for that period of time which means it's an excessive load on the server.
ghell
10-06-2004, 09:37 PM
although technically its 8 seconds not 1...
>_>
<_<
what!
BigDaddy
10-06-2004, 10:07 PM
I use a javascript function to accomplish the delay.
ghell
10-07-2004, 05:26 PM
you seem to be missing the point that meta refresh is far better and it was suggested already so every post after that is pretty much useless :p
BigDaddy
10-07-2004, 05:37 PM
You are right, actually. I use the javascript delay not to redirect, but to run a cleanup script that cleans up some session variables a few minutes after launching the page.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.