unr3al Posted October 3, 2010 Share Posted October 3, 2010 I want to modify this code: <!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>Download</title> </head> <body> <h2>Click the button below to download the working generator. Version 4.8 </h2> <p> <form><input type="button" value="Download Generator" onClick="window.location.href='/download.rar'"></form> <p> </body> </html> So that the button counts down from 5 seconds before people are able to click it. 1. Please wait 5 seconds 2. Please wait 4 seconds 3. Please wait 3 seconds 4. Please wait 2 seconds 5. Please wait 1 second 6. Download Generator Is that possible? Link to comment Share on other sites More sharing options...
0 DeathLace Posted October 3, 2010 Share Posted October 3, 2010 Typed real fast, but that should work pending any syntax errors. <!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>Download</title><script type="text/javascript">function countDown(var count){if(count == 0) { return true; }else {alert('Please wait ' + count + ' seconds');setTimeout(countDown(count-1), 1000);}}</script></head><body><h2>Click the button below to download the working generator. Version 4.8 </h2><p><form action="/download.rar"><input type="button" value="Download Generator" onsubmit="return countDown(5);"></form><p></body></html>[/CODE] Link to comment Share on other sites More sharing options...
0 unr3al Posted October 3, 2010 Author Share Posted October 3, 2010 Typed real fast, but that should work pending any syntax errors. <!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>Download</title><script type="text/javascript">function countDown(var count){if(count == 0) { return true; }else {alert('Please wait ' + count + ' seconds');setTimeout(countDown(count-1), 1000);}}</script></head><body><h2>Click the button below to download the working generator. Version 4.8 </h2><p><form action="/download.rar"><input type="button" value="Download Generator" onsubmit="return countDown(5);"></form><p></body></html>[/CODE] It doesn't like "function countDown(var count)". Could you please fix that? Link to comment Share on other sites More sharing options...
0 andrew_f Posted October 3, 2010 Share Posted October 3, 2010 <!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>Download</title> <script type="text/javascript"> function countDown(count) { if(count == 0) { return true; } else { alert('Please wait ' + count + ' seconds'); setTimeout(countDown(count-1), 1000); } } </script> </head> <body> <h2>Click the button below to download the working generator. Version 4.8 </h2> <form action="/download.rar" onsubmit="countDown(5);"><input type="submit" value="Download Generator" /></form> </body> </html> Would work. I'll post another solution in a minute which may be more what you are looking for. Link to comment Share on other sites More sharing options...
0 unr3al Posted October 3, 2010 Author Share Posted October 3, 2010 <!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>Download</title> <script type="text/javascript"> function countDown(count) { if(count == 0) { return true; } else { alert('Please wait ' + count + ' seconds'); setTimeout(countDown(count-1), 1000); } } </script> </head> <body> <h2>Click the button below to download the working generator. Version 4.8 </h2> <form action="/download.rar" onsubmit="countDown(5);"><input type="submit" value="Download Generator" /></form> </body> </html> Would work. I'll post another solution in a minute which may be more what you are looking for. Ya..that displays a message box..not what I'm lookin for. Thanks though! Link to comment Share on other sites More sharing options...
0 andrew_f Posted October 3, 2010 Share Posted October 3, 2010 Yeah, just I'll get what you are after in a minute, just squashing a bug on it - been a long while since I touched JS. Edit: this is rough, but might be more up your street - feel free for anyone to adapt and improve on this: <!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>Download</title> </head> <body> <h1>Downloader</h1> <p id="downloadLink">Enable JavaScript to download this file</p> <script type="text/javascript"> function getDownload(s,u){ var downloadLink = document.getElementById('downloadLink'); urlIntegrity = (u==undefined) ? u = downloadURL : downloadURL = u; if(s==0){ downloadLink.innerHTML = '<a href="'+u+'">Click here to download your file</a>'; } else { downloadLink.innerHTML = "Wait <span style='font-size:28px; font-weight: bold; color: red;'>"+s+"</span> more seconds..."; newSec = s-1; setTimeout("getDownload(newSec)", 1000); } } getDownload(5,"/download.rar"); </script> </body> </html> Link to comment Share on other sites More sharing options...
0 unr3al Posted October 3, 2010 Author Share Posted October 3, 2010 Yeah, just I'll get what you are after in a minute, just squashing a bug on it - been a long while since I touched JS. Edit: this is rough, but might be more up your street - feel free for anyone to adapt and improve on this: <!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>Download</title> </head> <body> <h1>Downloader</h1> <p id="downloadLink">Enable JavaScript to download this file</p> <script type="text/javascript"> function getDownload(s,u){ var downloadLink = document.getElementById('downloadLink'); urlIntegrity = (u==undefined) ? u = downloadURL : downloadURL = u; if(s==0){ downloadLink.innerHTML = '<a href="'+u+'">Click here to download your file</a>'; } else { downloadLink.innerHTML = "Wait <span style='font-size:28px; font-weight: bold; color: red;'>"+s+"</span> more seconds..."; newSec = s-1; setTimeout("getDownload(newSec)", 1000); } } getDownload(5,"/download.rar"); </script> </body> </html> Thanks, this works good. Link to comment Share on other sites More sharing options...
0 andrew_f Posted October 3, 2010 Share Posted October 3, 2010 Thanks, this works good. Not a problem, best of luck with it. Link to comment Share on other sites More sharing options...
0 unr3al Posted October 3, 2010 Author Share Posted October 3, 2010 Not a problem, best of luck with it. I really appreciate that code :) Are you any good with VB6? Link to comment Share on other sites More sharing options...
Question
unr3al
I want to modify this code:
So that the button counts down from 5 seconds before people are able to click it.
1. Please wait 5 seconds
2. Please wait 4 seconds
3. Please wait 3 seconds
4. Please wait 2 seconds
5. Please wait 1 second
6. Download Generator
Is that possible?
Link to comment
Share on other sites
8 answers to this question
Recommended Posts