Calling same function on pageload and on button click - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button

Description

Calling same function on pageload and on button click

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script>
function webservice()//from w  w  w  . j ava 2 s. c  o m
{
   for(var i=0;i<10;i++)
   {
      console.log("called");
   }
}
window.onload=function()
{
   webservice();
}

      </script> 
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
      <title>Insert title here</title> 
   </head> 
   <body> 
      <input id="webservice" type="button" name="webservice" value="Call Webservice" onClick="webservice()">  
   </body>
</html>

Related Tutorials