Thursday, May 19, 2016

How to write first JavaScript Pragram

First JavaScript Program

These below steps helps you write your first JavaScript program.

Windows

  1. Open notepad by going to Start -> Programs -> Accessories-> Notepad OR go to Start -> Run -> Type notepad and press Enter.

  2. Type in the following code:
    <html>
    <body>
    <script type="text/javascript">
    alert("My first Javascript program!");
    </script>
    </body>
    </html>
     
  3. Save the file as firstjavascript.html
    NOTE: Make sure that you give the file a .html extension and that you save it as type 'All Files', otherwise you will get plain text. 

  4. Open your web browser.

  5. Type into the web browsers location bar the absolute location of the directory where you saved your file along with the file name. For example, if you saved the file in C:\windows, type C:\windows\firstjavascript.html into the web browsers location bar.

  6. You should now see a blank document in your web browser which pops up an alert box that says "My first Javascript program!" in your web browser.

Linux

  1. Open nano and type in the following code:
    <html>
    <body>
    <script type="text/javascript">
    alert("My first Javascript program!");
    </script>
    </body>
    </html>
     
  2. Save the file as firstjavascript.html

  3. Open your web browser.

  4. Type into the web browsers location bar the absolute location of the directory where you saved your file along with the file name. For example, if you saved the file in /home/user1/desktop, type /home/user1/desktop/firstjavascript.html into the web browsers location bar.

  5. You should now get the file in your web browser which displays a blank page and pops up an alert box that says "My first Javascript program". 

    Hope you enjoy writing your first JavaScript program.  

No comments:

Post a Comment

Featured Post

RAR password retrieving with cRARk

cRARk is a .rar archive password retriever, but unlike rarcrack, can be customised to a far greater extent to allow partial passwords, wo...