Trouble with setTimeout(arg, arg)

Discussion in 'Javascript' started by nat.hourt@gmail.com, Nov 10, 2005.

  1. Guest

    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.
    , Nov 10, 2005
    #1
    1. Advertising

  2. web.dev Guest

    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.
    web.dev, Nov 10, 2005
    #2
    1. Advertising

  3. Evertjan. Guest

    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)
    Evertjan., Nov 10, 2005
    #3
  4. Guest

    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!
    , Nov 11, 2005
    #4
  5. Evertjan. Guest

    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)
    Evertjan., Nov 11, 2005
    #5
  6. Guest

    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! ;-)
    , Nov 11, 2005
    #6
  7. JRS: In article <>,
    dated Thu, 10 Nov 2005 14:19:39, seen in news:comp.lang.javascript,
    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.
    Dr John Stockton, Nov 11, 2005
    #7
  8. Guest

    Huh? NVM.

    I've fixed all of my problems. I haven't run into any other ones. Yet...
    , Nov 12, 2005
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hypo
    Replies:
    6
    Views:
    407
  2. Andy Pickering

    Smart navigation and js setTimeout

    Andy Pickering, Oct 24, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    492
    Andy Pickering
    Oct 27, 2003
  3. n00m
    Replies:
    5
    Views:
    396
  4. Weston C

    Trouble using setTimeout/setInterval

    Weston C, Feb 22, 2004, in forum: Javascript
    Replies:
    1
    Views:
    184
    Lasse Reichstein Nielsen
    Feb 22, 2004
  5. Replies:
    21
    Views:
    300
    Barry Schwarz
    Mar 5, 2014
Loading...

Share This Page