A simple JavaScript text loading animation.

Here is a simple text animation using JavaScript, this script displays loading text for a certain interval and then loads the website later. This script can be modified to show some message to user and redirect to some other site when the interval is elapsed.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<h4>Loading <span id="dots"></span></h4>
<script language="javascript">
var dotCnt = 0;
var secs = 0;
setInterval(function(){
 if( secs <= 6){
  dotCnt = dotCnt + 1;
  if(dotCnt >= 5){
   dotCnt = 0;
   document.getElementById("dots").innerHTML = ".";
  }else{
   document.getElementById("dots").innerHTML += ".";
  }
 }else{
  location.href = "http://www.google.com";
 }
 secs = secs + 1; 
}, 1000);

</script>

Some of the alternatives are also found like http://jsfiddle.net/cell21/1p1wmmuu/

from http://johnveldboom.com


Comments