Calling same js function on pageload and on button click and displaying both functions called
<p>I have a javascript function and I want to call the same function twice.
       Once on page load and once on a button click.
       I want the output as the function on page load will keep on running in backend and<br>
       display output and when button is clicked again function is called and its output 
       gets displayed.
       Finally both functions output should be displayed.
       This is what I have written but am not getting the output.</p>

<p>For e.g.</p>

<p>Javascript file: n.js</p>

<pre><code>function webservice{

   for(i=0;i&lt;10;i++)
   {
      alert("some msg");
      `enter code here`
   }
</code></pre>

<p>html file n.html</p>

<pre><code>   &lt;html&gt;
   &lt;head&gt;
   &lt;script type = "text/javascript" src="n.js"&gt;&lt;/script&gt;
   &lt;script type="text/javascript"&gt;

   window.onload=function() {
   webservice();
   }


   &lt;/script&gt;
   &lt;/head&gt;

   &lt;body&gt;

   &lt;input id="button"  type = "button" name = "webservice" value = "Call Webservice"      
   onClick="webservice()" /&gt;
   &lt;/body&gt;
   &lt;/html&gt;
</code></pre>
