Thursday, November 5, 2009

Basic Java script

1.What is JavaScript?

JavaScript: Interactivity to HTML pages .JavaScript is a Scripting Language. A scripting language is a lightweight programming language. JavaScript is an interpreted language. Everyone can use JavaScript without purchasing a license.



Example:
   1.                 < script type= ' text / JavaScript'>
                                document. write  ( ' Welcome To Java Script ! ' ) ;
                     < /script >      
2.         < script type="text/javascript" >
                      document.write("  <  h1  > This is a heading  <  /  h1  >" ) ;
                      document.write(" < p > This is a paragraph. < / p > " ) ;
                      document.write ( " < b > This is another paragraph. < / b > " ) ;
            < / script >




3.           //Display  a "Good morning"  if true
             //the time is less than 10

               var d=new Date();
              var time=d.getHours();

               if ( time < 10 )
              {
                       document.write ( "  Good morning " ) ;
             }

4.        function name is test()  just copy below script past to your HTML page. if we click on the button the     alert box will display that  I am an alert box!

            < Html  >
           < script type="text/javascript" >
             function test()
             {
                    alert ( " I am an alert box ! " ) ;
              }
           
< / script >


           < body  >
              < input type="button" onclick="test()" value="Show alert box" / >
           < / body  > 

< / Html  >
                      

No comments:

Post a Comment