...

View Full Version : Mission Code: Take your time



GSimpson
08-07-2006, 10:38 AM
Breifing:
At 2130 hours today I decided I want to produce a script that so many people are in the hunt for.

Now a certain person as commented to me that it impossible to do.

Mission:
To create a function that alerts you a Confirm message, that gives a choice to continue or not. if cancel obviously end function, but if ok,
continue to another alert. You cannot click ok on this next alert until the set time runs out. And Then Finally the final task of this is NO elements are to be used in this script.

Final Words:
Hooah!!!

MikoLone
08-07-2006, 08:41 PM
What do you mean "NO elements are to be used"?

MikoLone
08-07-2006, 08:56 PM
how is this?




var someamountoftime = 10000;
var timerDone = false;

document.onload = new function (){
firstConfirm = confirm("do you want to continue?");
if(firstConfirm){
mytimer = setTimeout("timersDone()",someamountoftime);
secondConfirm();
}
}

function timersDone(){
timerDone = true;
}

function secondConfirm(){
secondContinue = confirm("do you want to conitue again?");
if(secondContinue && timerDone){
alert("sweet");
}else{
secondConfirm();
}
}



Yeah you are right it does let them click the ok button but it pops it back up again until they have waited the amount of time that I set.

And I think there are no elements.

The html is.




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Mission</title>
<script language="javascript" type="text/javascript" src="mission.js"></script>
</head>

<body>
</body>
</html>

MikoLone
08-07-2006, 09:04 PM
It is impossible to kep people from clicking the ok button (I think) so I guess you could make your own popup using dhtml. which is possible but would be quite a bit of work.

GSimpson
08-08-2006, 12:13 AM
I'm not quite sure I explained that right,
So you click on a button for example
then you get a confirm box asking if you would like to continue -
If cancel then finsh function but if ok then display an alert for 10 seconds.
When the 10 seconds is up you can finish function and your variable goes up by one.

however we are making progress.
I was thinking timeouts? - but I dont know too much so...

MikoLone
08-08-2006, 04:48 PM
var someamountoftime = 10000;
var timerDone = false;
var countSomething = 0;

function startIt(){
firstConfirm = confirm("do you want to continue?");
if(firstConfirm){
mytimer = setTimeout("timersDone()",someamountoftime);
secondConfirm();
countSomething++;
}
}

function timersDone(){
timerDone = true;
}

function secondConfirm(){
alert("You will be able to continue in 10 seconds");
if(timerDone){
return;
}else{
secondConfirm();
}
}


But I would think that instead on an alert box I would make a div tag and pop that up instead. I hope this helps.

Kor
08-08-2006, 04:59 PM
It looks to me that your code will freeze the browser for ever on the last alert...

GSimpson
08-09-2006, 02:39 AM
Thanks alot Mike. I think I shall nominate you.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum