JavaScript Basic


  • We use <script> tag to insert javascript to a HTML document. Inside the script tag we use Type attribute to define the scripting language. It is optional to use the attribute of Language to define the script language.

  • JavaScript can be put under the header segment or body segment. Something needed to do before loading the page, you can define under header segment.
    Syntax: 
    <script language = "javascript" type = "text/javascript" >
    ------
    </script>

  • Opening tag of <script language = "javascript" type = "text/javascript" > and the closing tag of </script> tells where the JavaScript starts and ends.

  • To write some output to the HTML body we use standard JavaScript command of document.write() 
    Ex:
    <script language = "javascript" type = "text/javascript" >
    document.write("Hello!.. This is my 1st JavaScript Program");
    </script>


No comments:

Post a Comment