Click to See Complete Forum and Search --> : Timing is everything!!!
dmason165
03-20-2003, 11:17 AM
Hello all!
What would I have to do if I wanted to have a confirmation box only confirm if the user clicks the link which activates it within a certain time frame?
I have a page with an embedded video. When the user clicks the link to return to my homepage, a confirmation message asks if the user is sure they want to leave. However, if the user clicks this link after completing the video, than there is no need for a confirmation.
How do I make it so the confirmation will confirm only within X amount of time?
Thank you in advance for your time and your help!
~dmason165
<html><head>
<script>
function foo(){
if(confirm("Are you sure you want to leave?")){
location="http://somewhere.com/"
} }
function leave(){
//change 10 to however many seconds you want
setTimeout('foo()','10*1000');}
</script><body>
<a href="javascript:leave()">Leave?</a>
</body></html>
dmason165
03-20-2003, 04:54 PM
Jona,
Thank you for your reply. However, the JS you provided is not working:confused:
I also tried this:
<html>
<head>
<script language= "JavaScript">
function AreYouSure() {
var agree=confirm("Are you sure you want to exit?");
if (agree)
window.location= "Home3.htm";
}
function CancelConfirmation() {
setTimeout('AreYouSure(), 10000);//10 seconds used to test
}
</script>
</head>
<body>
<a href="javascript:AreYouSure()">Return Home</a>
</body>
</html>
This too did not work. I thought the setTimeout() wouold disable AreYouSure() after 10 seconds. But even after 10 seconds, the confirmation still popped up.
I also realized that the JS provided by Jona would not work anyway, because if AreYouSure() is disabled after 10 seconds, there is no reference to a page for the link to follow.
I welcome all suggestions!!
~dmason165
dmason165
03-20-2003, 06:09 PM
Hello all!
What would I have to do if I wanted to have a confirmation box only confirm if the user clicks the link which activates it within a certain time frame?
I have a page with an embedded video. When the user clicks the link to return to my homepage, a confirmation message asks if the user is sure they want to leave. However, if the user clicks this link after completing the video, than there is no need for a confirmation.
How do I make it so the confirmation will confirm only within X amount of time (while the video is NOT completed)?
I have tried this:
<html>
<head>
<script language= "JavaScript">
function AreYouSure() {
var agree=confirm("Are you sure you want to exit?");
if (agree)
window.location= "Home3.htm";
}
function CancelConfirmation() {
setTimeout('AreYouSure(), 10000);//10 seconds used to test
}
</script>
</head>
<body>
<a href="javascript:AreYouSure()">Return Home</a>
</body>
</html>
This did not work. I thought the setTimeout() would disable AreYouSure() after 10 seconds. But even after 10 seconds, the confirmation still popped up.
I also realized that the JS provided to me by Jona (in a previous thread) would not work anyway, because if AreYouSure() is disabled after 10 seconds, there is no reference to a page for the link to follow.
I welcome all suggestions and thank you in advance for your time and your help!!!
~dmason165
You have this: setTimeout('AreYouSure(), 10000);
It should be in quotes like this: setTimeout('AreYouSure()','10000');