Tutorials » Javascript tutorials »

Our first JavaScript program


Let us write a simple HTML page and learn how to embed Javascript in the HTML pages.

This is a simple program , just displays text message that is given by the user.

Type the following code in notepad or copy and paste it in the note pad.



<script text =”javascript">

document.write("Welcome to DotnetSpider Tutorials!");




Create a folder called JavaScript in D: Drive

Save the code that is written in notepad as First.Html

A file with extension .html is created.

The purpose of <script text =”javascript"> to tell the browser that it is JavaScript.
On the other hand document.write is used to write the output for the page.

What ever the text that is given in the “” that is executed.

Ending the statements with ‘;’ is not mandatory. It’s developer choice to omit or use.

But how ever semicolons are needed if we want to write more than one statement on a single line. But it is always a good practice to make our code as readable and beautify it proper indentation . So it's suggested to seperate the multiple statements ,instead of clubbing all the statements in a single line.

To run it:

Like how you run a simple HTML program just double click on the First.html Or Right click on the mouse and click on browse.

Now your first JavaScript Program is displayed on browser.

Next Chapter: Formatted text
Previous Chapter: Important points to make a note about JavaScript
More Chapters: Javascript Tutorials
More Tutorials: Tutorial Index

Top Contributors
    Last 7 Daysmore...

    Awards & Gifts
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India