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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sleep Function or something similar

Status
Not open for further replies.

biddingbong

IS-IT--Management
Sep 10, 2004
67
MU
In Visual Basic, we have the Sleep function.
The program will wait for some specified seconds and then will go to the next procedure.
Can this be done in asp?
Like show a page for 5 seconds, and after that 5 seconds then response.write will write something.
 
WScript.Sleep nTime

Where nTime is the time to pause for in milliseconds.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Actually, you don't want to sleep. Executing a sleep command in your ASP page will cause it to halt execution while it is still building the initial page. This means that even if you flush the buffer and force the current output to the client, when you continue writing you will still be outputting onto the same page. Not to mention the extra load you will put on your webserver by making that script take x + 5 seconds toload with each hit, will cause resource hogging and request pile-ups.

Instead I think what you want to do is either use a javascript function with a SetTimeout command to wait 5 seconds then change the page address, or a meta refresh tag to redirect to a second page after 5 seconds.

-T

barcode_1.gif
 
search google for "javascript loading message"

shows how to make a loading message that will show until the page is loaded, and then flips it to the content you want, without a redirect.

nice part about asp is you can force a .flush after the loading DIV so it's visible imediately, then chew the rest of the code out.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
*cough* or check the FAQs :) Two that I can remember off the top of my head, and I didn't write one of em ;)

barcode_1.gif
 
Its not a loading message.
The page will load normally,with all the tables, images, etc..
And after n Seconds, I want to response.write something on the page.
 
Look into using the javascript setTimeout in a client-side function then. Basically have your onLoad event in the body tag call the function. You can Response.Write all you want into that function then let the javascript take care of waiting the appropriate amount of time then either appending it to an existing span/div/etc or document.write'ing it to the screen.

Calling a sleep in ASP is to be avoided at all costs, for reasons mentioned earlier.

-T

barcode_1.gif
 
Anybody know if there is a vbscript equivalent to the setTimeout?

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
or you could do some awefull thing I saw the other day in a intranet application.

Do While NOT {some file found}
x=x+1
Loop

yup, still getting over it myself [lol]

___________________________________________________________________

onpnt.com
SELECT * FROM programmers WHERE clue > 0
(0 row(s) affected) -->faq333-3811

 
just use jscript for you scripting and then you can have the setTimeout function

___________________________________________________________________

onpnt.com
SELECT * FROM programmers WHERE clue > 0
(0 row(s) affected) -->faq333-3811

 
setTimeout is a window object function, and not available in ASP. On the client side, it should be the same in VBScript as in Javascript. Setting a timeout or sleep on the server side won't do what you want, but what Tarwn wrote will. Since you don't know the connection speed for an Internet viewer (this doesn't matter for intranet), you don't know how long it will take the page to get to the client, including any graphics. With a slow dialup connection, a server-side delay could mean no delay at all in the page displaying because of the lag for the dialup speed.

Lee
 
here's my approach:
have a setTimeout in javascript that will call redirect an iframe to an ASP page, get the iframe's innerHTML and write it to the main page.

maybe tht would solve it...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top