title: Calling nested function using javascript
body: <p>I have this code which calls a function test() on  body onload</p>
  
  <pre><code>&lt;body onLoad="test();"&gt;
  </code></pre>
  
  <p>The Test function has 2 more functions drawLayers() ,StopAll().</p>
  
  <pre><code>function test() {
  
    function drawLayers() {
     timers = [];
          timers.push(setTimeout(drawMoon,800));
         timers.push(setTimeout(drawCircle1,2300));
          timers.push(setTimeout(drawCircle2,2700));
      timers.push(setTimeout(drawCircle3,3100));
          timers.push(setTimeout(drawCircle4,3500));
          timers.push(setTimeout(drawCircle5,3900));
          timers.push(setTimeout(drawtext2,4300));
          timers.push(setTimeout(drawtext,4700));
          timers.push(setTimeout(drawtext3,5100));
          timers.push(setTimeout(drawtext4,5500));
          timers.push(setTimeout(drawtext5,5900));
          timers.push(setTimeout(drawtext6,6300));
          timers.push(setTimeout(drawtext7,6700));
          timers.push(setTimeout(drawtext8,7100));
          timers.push(setTimeout(drawtext9,7500));
          timers.push(setTimeout(drawtext10,7900));
  
  
  
      }
  
   function StopAll() {
       alert('fsdfsdf');
          for (var i = 0; i &lt; timers.length; i++)
               window.clearTimeout(timers[i]);
      }
  }
  </code></pre>
  
  <p>What i want to do is  Call the StopAL() function on click of a button, the html code looks like below</p>
  
  <pre><code>&lt;a href="javascript:void(0);" onClick="StopAll();"&gt;
  </code></pre>
  
  <p>Its throwing error, "StopAll is not defined"</p>
  
  <p>How do i call the StopALL() function?</p>