blenderNetworkpatreonblender-logosdheartuserthtimesbookphotopencilmap-markerchevron-rightbancommentcommentstwitterfacebookrsschainnavicongoogle-plusenvelopelinkedinmail-replycalendar-otumblrredditstumbleuponshare-altbloggerflattrflag

Making download links.

Re: Making download links.

Postby IrascibleOne » February 13th, 2011, 12:59 pm

Ah, I know what's going on. You have a recursive function with no way out, creating in infinite loop.

Right now the function calls itself every single time through the setTimeout function, no matter what. What you need to do is tell the function to only run the setTimeout function when the time is greater than 0.

What you can do is set the timer to a variable:

Code: Select all
var timer = setTimeout(countdown, 1000);


Then in your if statement, add the clearTimeout function, to stop the timer:

Code: Select all
if (number<0) {
     window.location.href = 'Downloads/Episode 2.zip';
     number = 0;
     clearTimeout(timer);
}


This way, once you have told the browser to begin the downloading, the timer will be stopped and it won't call the countdown function again, effectively killing the loop.
Image
User avatar
IrascibleOne
Site Admin
Site Admin
 
Posts: 1539
Joined: July 31st, 2008, 7:14 pm

Re: Making download links.

Postby themitchel0 » February 13th, 2011, 1:22 pm

thanks irascrible!
themitchel0
Pro
Pro
 
Posts: 365
Joined: June 15th, 2010, 8:31 am
Previous
Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron