Video of Day

Hello world in Java Script


JavaScript is an interpreted language. That means: no compilation. You just write code and attach it to HTML.


 <!DOCTYPE HTML>  
 <html>  
 <body>  
 <p>Header...</p>  
  <script>  
  alert('Hello, World!')  
 </script>  
  <p>...Footer</p>  
 </body>  
 </html>  
The simplest way is to put JavaScript directives into SCRIPT tag somewhere inside the page.
Here is a SCRIPT tag containing single JavaScript statement. Please click the ‘Show’ button to see the example.

Note that contents of the SCRIPT block is not shown, instead, it is executed.
This example makes use of following elements:
<script> ... </script>
<script> tag tells browser that there is executable content inside. In older HTML standard, namely HTML4, a special attribute type was required. Although more up-to-date HTML5 makes it optional.
Browser:
  1. Starts showing the page, shows Header
  2. Switches to JavaScript mode inside this tag and executes the contents of <script>
  3. Returns back to HTML-mode and continues with the page, outputs Footer.
alert(...)
Outputs a message window on the screen and awaits until visitor presses OK


Tag:
java script
hello world

Share on Google Plus

About Admin

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment