Sunday, 11 August 2013

java script function

A function is written as a code block (inside curly { } braces), preceded by the function keyword:
function functionname()
{
some code to be executed
}
The code inside the function will be executed when "someone" calls the function.

The function can be called directly when an event occurs (like when a user clicks a button), and it can be called from "anywhere" by JavaScript code.

JavaScript is case sensitive. The function keyword must be written in lowercase letters, and the function must be called with the same capitals as used in the function name.

<html>
 <head>
  <script type="text/javascript">
   function display()
   {
     document.write("welcome to java script");
   }
  </script>
 </head>
 <body onload=display()>
 </body>
</html>

output:




No comments:

Post a Comment