Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Trouble with setTimeout(arg, arg)

Reply
Thread Tools

Trouble with setTimeout(arg, arg)

 
 
nat.hourt@gmail.com
Guest
Posts: n/a
 
      11-10-2005
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.

 
Reply With Quote
 
 
 
 
web.dev
Guest
Posts: n/a
 
      11-10-2005

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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.

 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      11-10-2005
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)

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

 
Reply With Quote
 
nat.hourt@gmail.com
Guest
Posts: n/a
 
      11-11-2005
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!

 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      11-11-2005
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.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

 
Reply With Quote
 
nat.hourt@gmail.com
Guest
Posts: n/a
 
      11-11-2005
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!

 
Reply With Quote
 
Dr John Stockton
Guest
Posts: n/a
 
      11-11-2005
JRS: In article <(E-Mail Removed). com>,
dated Thu, 10 Nov 2005 14:19:39, seen in news:comp.lang.javascript,
(E-Mail 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'.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
 
Reply With Quote
 
nat.hourt@gmail.com
Guest
Posts: n/a
 
      11-12-2005
Huh? NVM.

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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
i have no trouble to send , ihave trouble reciving mail --any ideas John Penney Computer Support 4 08-29-2006 08:45 PM
having trouble securing my wireless laptop FireBrick Wireless Networking 2 08-10-2004 12:37 PM
Trouble staying connected to wifi Michael Giroux Wireless Networking 1 08-03-2004 08:33 PM
Trouble connecting in public hot spots Andres Perez Wireless Networking 2 07-16-2004 06:47 PM
trouble with caching or caching the trouble Hypo ASP .Net 6 08-01-2003 07:11 AM



Advertisments