setTimeout

S

Simon

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?
 
E

Evertjan.

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)
 
S

Simon

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...430448788&^VAR(LID,7)=^TO2001300B&DIS=KOSTENB"
;
if
('http://10.10.25.197/scripts/mgwms32...430448788&^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;
}
 
R

RobG

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.
 
S

Simon

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 said:
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.
 
R

RobG

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>
 
S

Simon

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.
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]
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.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top