Saturday

loading... animation for buttons and such

sometimes I like to have a little loading animation using just the button label, so here is a snippet to generate the string - it does the little dots-increase that we all know from elsewhere.


var c=0,t,dots='Loading';
function loadanim(){
while(c<=12){ c++; c %4 == 0 ? dots='Loading ' : dots += '.'; document.getElementById('txt').value=dots; t=setTimeout("loadanim()",300); return dots; } if(c>=13) {
clearTimeout(t);
}
}

1 comment:

Anonymous said...

i gotta say, the blogger system SUCKS!

Look at this crazy formatting. And it just WONT let me keep things inside the PRE tags with appropriate carriage returns. WTF!?