setTimeout

Discussion in 'Javascript' started by Simon, Mar 15, 2007.

  1. Simon

    Simon Guest

    Hi everybody

    I have a function, called "Terug"
    Within that function i want to go to another function (named Frames) after
    let's say, 2 seconds.
    How can I do that?

    function Terug() {
    some code
    etc etc
    etc etc

    window.setTimeout(Frames,2000)
    }
    Function Frames() {
    alert ('hello');
    }

    This doesn't work.
    Any ideas?
     
    Simon, Mar 15, 2007
    #1
    1. Advertising

  2. Simon

    Evertjan. Guest

    Simon wrote on 15 mrt 2007 in comp.lang.javascript:

    > window.setTimeout(Frames,2000)
    >}
    > Function Frames() {
    > alert ('hello');
    >}
    >
    > This doesn't work.
    >


    setTimeout(Frames(),2000)

    Voor oude browsers zelfs:

    setTimeout('Frames()',2000)

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Mar 15, 2007
    #2
    1. Advertising

  3. Simon

    Simon Guest

    Ok thanks, but when i place it in an "if-argument" it does go to the next
    function but it doesn't wait for two seconds anymore..
    This is the script: If the first url is equal to the next url (like it is in
    my example) it must wait 2 seconds and then continue with function Frames().

    function Terug() {
    location.href =
    "http://10.10.25.197/scripts/mgwms32.dll?MGWLPN=TONED&LID=6070430448788&^VAR(LID,7)=^TO2001300B&DIS=KOSTENB"
    ;
    if
    ('http://10.10.25.197/scripts/mgwms32.dll?MGWLPN=TONED&LID=6070430448788&^VAR(LID,7)=^TO2001300B&DIS=KOSTENB'=='http://10.10.25.197/scripts/mgwms32.dll?MGWLPN=TONED&LID=6070430448788&^VAR(LID,7)=^TO2001300B&DIS=KOSTENB')
    {
    window.setTimeout(Frames(),2000);
    }
    }
    function Frames() {
    if(parent.framesetgbv.cols=='0,*')
    { btr='700,*' }
    else { btr=parent.framesetgbv.cols }
    if (parent.framesetgbv.cols == "0,*")
    {FrameSize = "700,*" }
    if (parent.framesetgbv.cols == btr)
    { FrameSize = "0,*" }
    parent.framesetgbv.cols = FrameSize;
    }

    "Evertjan." <> schreef in bericht
    news:Xns98F480115C3BCeejj99@194.109.133.242...
    > Simon wrote on 15 mrt 2007 in comp.lang.javascript:
    >
    >> window.setTimeout(Frames,2000)
    >>}
    >> Function Frames() {
    >> alert ('hello');
    >>}
    >>
    >> This doesn't work.
    >>

    >
    > setTimeout(Frames(),2000)
    >
    > Voor oude browsers zelfs:
    >
    > setTimeout('Frames()',2000)
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)
     
    Simon, Mar 15, 2007
    #3
  4. Simon

    RobG Guest

    On Mar 15, 10:24 pm, "Simon" <> wrote:
    > Ok thanks,


    Please don't top-post, reply below trimmed quotes.

    > but when i place it in an "if-argument" it does go to the next
    > function but it doesn't wait for two seconds anymore..


    You didn't follow Evertjan's post closely enough...

    [...]

    > window.setTimeout(Frames(),2000);



    setTimeout( 'Frames()', 2000 );}

    Note the quotes around the function call - without them, the function
    is executed immediately. There is also no need to include the window
    object reference.


    --
    Rob
     
    RobG, Mar 15, 2007
    #4
  5. Simon

    Simon Guest

    I'm sorry, don't know how this works. (Newsgroup) I will figure out what you
    mean by top-posting.

    When I place the '-mark around the functioncall it doesnt work at all.





    "RobG" <> schreef in bericht
    news:...
    > On Mar 15, 10:24 pm, "Simon" <> wrote:
    >> Ok thanks,

    >
    > Please don't top-post, reply below trimmed quotes.
    >
    >> but when i place it in an "if-argument" it does go to the next
    >> function but it doesn't wait for two seconds anymore..

    >
    > You didn't follow Evertjan's post closely enough...
    >
    > [...]
    >
    >> window.setTimeout(Frames(),2000);

    >
    >
    > setTimeout( 'Frames()', 2000 );}
    >
    > Note the quotes around the function call - without them, the function
    > is executed immediately. There is also no need to include the window
    > object reference.
    >
    >
    > --
    > Rob
    >
     
    Simon, Mar 15, 2007
    #5
  6. Simon

    RobG Guest

    On Mar 15, 11:06 pm, "Simon" <> wrote:
    > I'm sorry, don't know how this works. (Newsgroup) I will figure out what you
    > mean by top-posting.


    Top-posting is putting your reply at the top and leaving the post that
    you are replying to at the bottom. It is much more efficient to trim
    the stuff you aren't interested in and reply below the bits you want
    to comment on.

    Read a few other posts here to get the idea.


    > When I place the '-mark around the functioncall it doesnt work at all.


    Then you have some other error - try the following simple example:

    <script type="text/javascript">

    function sayHi(){alert('Hi');}

    function foo() {
    setTimeout('sayHi();', 2000);
    }

    foo();

    </script>


    --
    Rob
     
    RobG, Mar 15, 2007
    #6
  7. Simon

    Guest

    On Mar 15, 7:06 am, "Simon" <> wrote:

    > When I place the '-mark around the functioncall it doesnt work at all.
    >


    Try -
    setTimeout(function(){ Frames() },2000);
     
    , Mar 15, 2007
    #7
  8. Simon

    Simon Guest


    > Try -
    > setTimeout(function(){ Frames() },2000);


    Thanks, i tried it, but, unfortunately, it doesn't work. Does it have
    something to do with the if-argument?
    The line that worked best so far was: setTimeout(Frames,2000);
    Only now it goes immediately to the function Frames, and totally ignores the
    2 seconds.
     
    Simon, Mar 16, 2007
    #8
  9. In comp.lang.javascript message <
    glegroups.com>, Thu, 15 Mar 2007 06:34:29, RobG <>
    posted:
    >On Mar 15, 11:06 pm, "Simon" <> wrote:
    >> I'm sorry, don't know how this works. (Newsgroup) I will figure out what you
    >> mean by top-posting.

    >
    >Top-posting is putting your reply at the top and leaving the post that
    >you are replying to at the bottom. It is much more efficient to trim
    >the stuff you aren't interested in and reply below the bits you want
    >to comment on.
    >
    >Read a few other posts here to get the idea.


    Better IMHO to say "Read FAQ 2.3 paragraph 6", and give the URL of the
    FAQ. That way, the questioner is encouraged to learn more than by
    reading a few past articles.

    A. <FAQENTRY> Even if the paragraphs of 2.3 cannot be sub-numbered as
    by <OL>, it's always possible to type the necessary digits (or letter)
    at the beginning of each paragraph. But it would be better split into
    Reading, Asking, Replying, preceded by General.

    --
    (c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
    news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
    <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 J R Stockton, Mar 16, 2007
    #9
    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. Andy Pickering

    Smart navigation and js setTimeout

    Andy Pickering, Oct 24, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    500
    Andy Pickering
    Oct 27, 2003
  2. j van c

    settimeout

    j van c, Dec 5, 2003, in forum: HTML
    Replies:
    5
    Views:
    493
    Nico Schuyt
    Dec 7, 2003
  3. JR

    setTimeout

    JR, Apr 15, 2004, in forum: HTML
    Replies:
    3
    Views:
    542
    Whitecrest
    Apr 15, 2004
  4. =?Utf-8?B?RQ==?=

    javascript setTimeout does not work

    =?Utf-8?B?RQ==?=, May 2, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    8,809
    =?UTF-8?B?R8O2cmFuIEFuZGVyc3Nvbg==?=
    May 2, 2006
  5. Colin Brown

    socket settimeout ?

    Colin Brown, Dec 3, 2003, in forum: Python
    Replies:
    0
    Views:
    614
    Colin Brown
    Dec 3, 2003
Loading...

Share This Page