Trouble with setTimeout(arg, arg)

N

nat.hourt

Hello.

First, I'm going to tell you what I'm trying ultimately to do, then
I'll tell you how I'm trying to do it.

I am trying to get an intro page to a site I am designing which will
play an animated GIF file once, then go on to another page. The way I'm
doing this is having the GIF play up outside of the JS while the JS
counts MS until it finishes. I want the JS to wait 2 seconds/2000 MS
for the GIF anim, then go to another page. Here is my JS:

setTimeout("2000", 'location.href="the_next_page.htm"')

I believe that should do it?

Note: I use Fx, but I want this to work correctly in IE too.
 
W

web.dev

Hello.

First, I'm going to tell you what I'm trying ultimately to do, then
I'll tell you how I'm trying to do it.

I am trying to get an intro page to a site I am designing which will
play an animated GIF file once, then go on to another page. The way I'm
doing this is having the GIF play up outside of the JS while the JS
counts MS until it finishes. I want the JS to wait 2 seconds/2000 MS
for the GIF anim, then go to another page. Here is my JS:

setTimeout("2000", 'location.href="the_next_page.htm"')

I believe that should do it?

Note: I use Fx, but I want this to work correctly in IE too.

You've got it backwards, it should be the following instead:

setTimeout("locatio.href='next_page.htm'", 2000);

The amount of time should not be a string either.
 
E

Evertjan.

wrote on 10 nov 2005 in comp.lang.javascript:
setTimeout("2000", 'location.href="the_next_page.htm"')

wrong parameter position.

function next(){
location.href="the_next_page.htm"
}
setTimeout('next()',2000)
 
N

nat.hourt

OK, thanks. I feel really stupid now. Is there any such thing as a JS
IDE? Intellisense, the works?

Evertjan, you are Dutch? Nice. My mom grew up in Holland!
 
E

Evertjan.

wrote on 11 nov 2005 in comp.lang.javascript:

[please always quote on usenet, this is not email]
OK, thanks. I feel really stupid now. Is there any such thing as a JS
IDE? Intellisense, the works?

dunnow. Javascript is a joy in itself.
Evertjan, you are Dutch? Nice.

for me, yes.
My mom grew up in Holland!

That is west of here, I live in the Netherlands.
 
N

nat.hourt

Try this one:

var Holland == "The Netherlands";

Anyways, I've run across another problem now. The GIF I made is not
very small, and the method used above will not give it time to load. I
have made a preload page with the code

var img1 = new Image();
img1.src = "Image's URL";
location.href = "intropage.htm";

I want it to preload the image, then forward me to the page with the
GIF. However, I soon discovered that it does not wait for the preload
to finish. It simply continues with the code. Is there any way to make
the JS wait until the image has been fully loaded before continuing?

Is there an img1.loaded or something of the sort variable? Then I could
just use a loop to check it every second or so, and if it was loaded
then I could have an if() condition forward the page... Is this
possible?

And if it is, you'll have to refresh my memory on JS loops. I know
there are a bunch of them, and I haven't used JS in quite some time.

P.S. Thanks for your help so far! ;-)
 
D

Dr John Stockton

JRS: In article <[email protected]>,
dated Thu, 10 Nov 2005 14:19:39, seen in (e-mail address removed) posted :
setTimeout("2000", 'location.href="the_next_page.htm"')

I believe that should do it?


Better results may be obtained with the parameters in a different order.
If you had read the oft-posted newsgroup FAQ before posting, as is
considered courteous and prudent, you should have noted that. The delay
does not need to be a string. And 'MS' means MegaSiemens, a conductance
corresponding to a resistance of a micro-ohm. Milliseconds are
indicated by 'ms'.
 
N

nat.hourt

Huh? NVM.

I've fixed all of my problems. I haven't run into any other ones. Yet...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top