My Adsense

Wednesday, November 9, 2011

Javascript Basics : Part 1 (Hello world)

Now a days, the most basic thing a web application developer must know is Javascript. So, what is javascript? probably know Javascript is nothing to do with Java. Javascript is totally different with Java. In syntax, in semantic, in usage, in all aspects. So, Javascript is a scripting language which runs in browser. The browser software executes the script line by line, from top to bottom, and display you the output.

Now what you can guess, Javascript must be embedded in a HTML file and when the HTML codes are rendered/executed, Javascript codes get executed with those. If you want to let your browser know that you are writing a Javascript code, you must add some extra tags/codes with the statements. For example:

What you can see, at the above code, by the ‘document.write’ method, we are writing some text in the browser. But we need to add the 'script' tag having the type as javascript with it.
If the browser executes this line of code, we can view ‘Javascript is very easy’  text on the browser.
So, the total html code should be

To do this by yourself, follow the below steps:

1. Open notepad
2. Copy and paste the above html code (with Javascript)
3. Save the file as ‘FirstPage.html’
4. Close the file
5. Double click on your just created ‘Firstpage.html’ file
6. You should see the below output

Ok. so we made something which is running. Its amazing when we get something running.
In next post, we will talk about the javascript functions.

1 comment:

Jasmin's Blog said...

I liked your writing style.It gives a clear concept about javascript how it works and how it can be used in web application.I think its really useful to get a starting concept for javascript beginners...keep it up...:-)