• 0

HTML Question


Question

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

8 answers to this question

Recommended Posts

  • 0

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

  • 0

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

  • 0

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Download&lt;/title&gt;
&lt;script type="text/javascript"&gt;
function countDown(count)
{
if(count == 0) { return true; }
else {
alert('Please wait ' + count + ' seconds');
setTimeout(countDown(count-1), 1000);
}
}
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;h2&gt;Click the button below to download the working generator. Version 4.8 &lt;/h2&gt;
&lt;form action="/download.rar" onsubmit="countDown(5);"&gt;&lt;input type="submit" value="Download Generator"  /&gt;&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

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

  • 0

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Download&lt;/title&gt;
&lt;script type="text/javascript"&gt;
function countDown(count)
{
if(count == 0) { return true; }
else {
alert('Please wait ' + count + ' seconds');
setTimeout(countDown(count-1), 1000);
}
}
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;h2&gt;Click the button below to download the working generator. Version 4.8 &lt;/h2&gt;
&lt;form action="/download.rar" onsubmit="countDown(5);"&gt;&lt;input type="submit" value="Download Generator"  /&gt;&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

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

  • 0

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:

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Download&lt;/title&gt;

&lt;/head&gt;

&lt;body&gt;
&lt;h1&gt;Downloader&lt;/h1&gt;
&lt;p id="downloadLink"&gt;Enable JavaScript to download this file&lt;/p&gt;
&lt;script type="text/javascript"&gt;

function getDownload(s,u){
	var downloadLink = document.getElementById('downloadLink');
	urlIntegrity = (u==undefined) ? u = downloadURL : downloadURL = u;

	if(s==0){
		downloadLink.innerHTML = '&lt;a href="'+u+'"&gt;Click here to download your file&lt;/a&gt;';
	} else {
		downloadLink.innerHTML = "Wait &lt;span style='font-size:28px; font-weight: bold; color: red;'&gt;"+s+"&lt;/span&gt; more seconds...";
		newSec = s-1;
		setTimeout("getDownload(newSec)", 1000);
	}
}

getDownload(5,"/download.rar");

&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;

Link to comment
Share on other sites

  • 0

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:

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Download&lt;/title&gt;

&lt;/head&gt;

&lt;body&gt;
&lt;h1&gt;Downloader&lt;/h1&gt;
&lt;p id="downloadLink"&gt;Enable JavaScript to download this file&lt;/p&gt;
&lt;script type="text/javascript"&gt;

function getDownload(s,u){
	var downloadLink = document.getElementById('downloadLink');
	urlIntegrity = (u==undefined) ? u = downloadURL : downloadURL = u;

	if(s==0){
		downloadLink.innerHTML = '&lt;a href="'+u+'"&gt;Click here to download your file&lt;/a&gt;';
	} else {
		downloadLink.innerHTML = "Wait &lt;span style='font-size:28px; font-weight: bold; color: red;'&gt;"+s+"&lt;/span&gt; more seconds...";
		newSec = s-1;
		setTimeout("getDownload(newSec)", 1000);
	}
}

getDownload(5,"/download.rar");

&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;

Thanks, this works good.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.