|
-
Apr 20th, 2002, 12:03 PM
#1
Settimeout2
hELLO
I have just tried to write asmall script but...
I had some problems..
***using settimeout....I wanted my program to alert me (helloooo)...when the "seconds==5//// and then when the seconds==10 ..let it say "goodmorning" or change bgcolor to red or showme an image if the second ==20...
Hope you got me..Thanks
-
Apr 20th, 2002, 04:39 PM
#2
PowerPoster
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Apr 20th, 2002, 10:41 PM
#3
Fanatic Member
Code:
<head>
<script language="JavaScript">
var number = 0;
function timer() {
time = setTimeout("randomEvent()",5000);
}
function randomEvent() {
switch(number) {
case 0:
alert("Hello");
break;
case 1:
document.bgColor = "#CC0000";
break;
case 2:
window.open("image.html");
break;
}
number++;
if (number == 3)
number = 0;
clearTimeout(time);
timer();
}
</script>
</head>
<body onLoad="timer();" bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
</body>
-Matt
-
Apr 21st, 2002, 07:55 AM
#4
try this
Code:
<head>
<script language="JavaScript">
var number = 0;
var timeincrement = 5000;
function timer() {
time = setTimeout("randomEvent()",timeincrement);
timeincrement += 5000;
}
function randomEvent() {
switch(number) {
case 0:
alert("Hello");
break;
case 1:
document.bgColor = "#CC0000";
break;
case 2:
window.open("image.html");
break;
}
number++;
if (number == 3)
number = 0;
clearTimeout(time);
timer();
}
</script>
</head>
<body onLoad="timer();" bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
</body>
-
Apr 21st, 2002, 10:39 AM
#5
Fanatic Member
Originally posted by mendhak
try this
Code:
<head>
<script language="JavaScript">
var number = 0;
var timeincrement = 5000;
function timer() {
time = setTimeout("randomEvent()",timeincrement);
timeincrement += 5000;
}
function randomEvent() {
switch(number) {
case 0:
alert("Hello");
break;
case 1:
document.bgColor = "#CC0000";
break;
case 2:
window.open("image.html");
break;
}
number++;
if (number == 3)
number = 0;
clearTimeout(time);
timer();
}
</script>
</head>
<body onLoad="timer();" bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
</body>
Doing it that way produces the alert at 5 seconds, but then the background change happens at 15 seconds and not 10.
Whereas on mine, I just reset the timer so it runs another 5 seconds which when added with the before 5 seconds it equals 10 and not 15.
-Matt
-
Apr 21st, 2002, 11:22 PM
#6
Houston, we're experiencing communication and interpretation problems here! Get me outta here!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|