title: How to create a infinite screen screensaver like in windows xp using javascript
body: <p>## I have just tried a idle screensaver thats not working properly.. I expected for screensaver like windows xp text animates inifinitly ##</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function(){
      animateDiv();
      
  });
  
  function makeNewPosition(){
      
      
      var h = $(window).height() - 50;
      var w = $(window).width() - 50;
      
      var nh = Math.floor(Math.random() * h);
      var nw = Math.floor(Math.random() * w);
      
      return [nh,nw];    
      
  }
  
  function animateDiv(){
      var newq = makeNewPosition();
      $('.a').animate({ top: newq[0], left: newq[1] }, function(){
        animateDiv();        
      });
      
  };</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>div.a {
  width: 50px;
  height:50px;
   background-color:red;
  position:fixed;
      
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class='a'&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <blockquote>
    <p>Animation done through pure <code>javascript</code></p>
  </blockquote>