Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time'd "Ok" button for javascript alert box w/redirect

Status
Not open for further replies.

fmb2125

IS-IT--Management
Joined
Apr 6, 2005
Messages
1
Location
US
I'm trying to make a script that keeps a user on a webpage for "x" amount of time, before redirecting them back to our start page. As it stands right now, I have it so the dialog box pops open and stays there until the time runs out, clicking on the "ok" button only pops up the dialog box again. What I'm trying to do is make it so the "Ok" button only appears after the time runs out. I'm not even sure this can be done, but any help people can give me would be greatly appreciated.

Here's the code I have right now...

<html>
<head>
<title>Redirectz0r</title>
<script langauge="JavaScript">
<!-- hide me

function announceTime()
{
//get the date, the hour, minutes, and seconds
var the_date = new Date();
var the_hour = the_date.getHours();
var the_minute = the_date.getMinutes();
var the_second = the_date.getSeconds();

var done = the_second + 15;
//put together the string and alert with it
var the_time = the_hour + ":" + the_minute + ":" + the_second;
//alert("The time is now: " + the_time);
//alert(the_second);
for(var i = the_second; i <= done; i++) {
alert("You must wait, you bastard!");
}
location.href="}

// show me -->
</script>

</head>
<body onLoad="announceTime();">

...

</body>
</html>
 
Use a setTimeout with whatever time delay you want to call your function that displays the alert box. The following waits 1 minutes (6000 milliseconds) before displaying the alert:

Code:
onLoad="setTimeout('announceTime()', 6000);">

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top