PDA

View Full Version : timer help ($$)


Al_90
07-18-2005, 10:21 PM
i need a javascript script that when the page loads it starts ticking away untill it reaches 100 then it displays a message that says File Downloaded Sucessfully, thanks! there will b $$ involved if it works and you can prove that it works i av been ripped b-for

Jalenack
07-18-2005, 10:24 PM
function init () {
setTimeout('doAlert()', 1000*100)
}

function doAlert() {
alert('Your file has finished downloading...');
}

window.onload = init;


This will make the alert after 100 seconds..Anything thing else it needs to do?

Al_90
07-18-2005, 10:31 PM
can u put it in html form so alli av to do is copy and paste and i need the 100 seconds to show up on the page and start as soon as the page is loaded, thanks

Al_90
07-18-2005, 10:34 PM
and i forgot it goes 0-100 in 10 seconds, god i hope this is possible

Jalenack
07-18-2005, 10:34 PM
<html>
<head>
<script type="text/javascript">
function init () {
setTimeout('doAlert()', 1000*10)
}

function doAlert() {
alert('Your file has finished downloading...');
}

window.onload = init;
</script>
</head>
<body>
Hello World
</body>
</html>


Or do you want it to show its progress on the page, and when it reaches 100, it alerts a message?

Al_90
07-18-2005, 10:37 PM
u posted this before my other post, sry mate

Jalenack
07-18-2005, 10:48 PM
<html>
<head>
<script type="text/javascript">
var i = 0;

function init () {
Interval = setInterval('doStuff()', 100)
}

function doStuff () {
i++;
document.getElementById('counter').innerHTML = i;
if (i == 100) {
alert('Your file has finished downloading...');
clearInterval(Interval);
}
}

window.onload = init;
</script>
</head>
<body>
<span id="counter"></span> percent is done
</body>
</html>

Al_90
07-18-2005, 11:01 PM
thanks so much!! if u want $$ tell me ur paypall. btw i added it and it workd alone but when i added it to my page it didnt any suggestions?

<html>
<head>
<script language="JavaScript1.2" type="text/javascript">
timeOut_period = 8; // measured in seconds

function endMySession() {
setTimeout("window.close(self);", timeOut_period*1000);
}

function performCountdown() {
timeOut_period = timeOut_period - 1;
setTimeout("performCountdown();", 1000);
defaultStatus = timeOut_period + " seconds to termination";
}
</script>
<script type="text/javascript">
var i = 0;

function init () {
Interval = setInterval('doStuff()', 100)
}

function doStuff () {
i++;
document.getElementById('counter').innerHTML = i;
if (i == 100) {
alert('File Downloaded');
clearInterval(Interval);
}
}

window.onload = init;
</script>
</head>
<body onload="endMySession(); performCountdown();">
<span id="counter"></span>% Downlaoded
</body>
</html>

Jalenack
07-18-2005, 11:07 PM
Yes, because you are calling multiple onload functions at once.. here:

<html>
<head>
<script type="text/javascript">
timeOut_period = 8; // measured in seconds

function endMySession() {
setTimeout("window.close(self);", timeOut_period*1000);
}

function performCountdown() {
timeOut_period = timeOut_period - 1;
setTimeout("performCountdown();", 1000);
defaultStatus = timeOut_period + " seconds to termination";
}
</script>
<script type="text/javascript">
var i = 0;

function init () {
Interval = setInterval('doStuff()', 100);
endMySession();
performCountdown();
}

function doStuff () {
i++;
document.getElementById('counter').innerHTML = i;
if (i == 100) {
alert('File Downloaded');
clearInterval(Interval);

}
}

window.onload = init;
</script>
</head>
<body>
<span id="counter"></span>% Downlaoded
</body>
</html>


Although it looks like you've set your page to close the window before it reaches 100%...

I've sent a PM to you with paypal info.

Jalenack
07-18-2005, 11:10 PM
You should know, that at least in Firefox, you can't make javascript close a window that it didn't even open.

Al_90
07-18-2005, 11:14 PM
You should know, that at least in Firefox, you can't make javascript close a window that it didn't even open.
then how can i fiz that i need the window to close after the alert pops-up and the payment will b sent ASAP

Jalenack
07-18-2005, 11:19 PM
the only way to close the window would be to have it opened from another page in a new window. So you'd have to create a new window with this script in it, and then close it again.