Javascript Introduction
What is JavaScript?

Javascript is a client side scripting language.
Javascript is used for developing web page.
Javascript is used to detect browser.
Javascript syntax match to C++, Java.
Javascript was created in September 1995. Java script developed by Brendan Eich(Netscape programmer).

Advantage of JavaScript.

Validating user data on client side.
There is no need to buy extra software means no expensive for Javascript. we can use any plain text(notepad) or any HTML editor like Dreamweaver.

Use of Javascript

Validate Form before submitting the form on the server.
Navigation menu for website.
Javascript use to maintain cookies.
We can read and change the content of HTML elements.
we can develope slide show means change image automatically one by one.

How to Create Javascript code.

Javascript is written inside HTML code. For write Javascript code inside HTML. Use <script> tag.

<script language="javascript">
..........
..........
..........
</script>

We can write javascript code inside <head></head> and <body></body>

When we write Javascript code inside head tag. Then we can call Javascript code on html tag event.
Like onclick(),onfocus() etc. But In the body tag this is not possible.

Javascript in BODY Section.

<html>
<head>
<title>my first Javascript code</title>
</head>
<body>
<script language="javascript">
document.write('welcome');
</script>
</body>
</html>

Javascipt in HEAD Section

<html>
<head>
<title>my first Javascript code</title>
<script language="javascript">
document.write('welcome');
</script>
</head>
<body>
</body>

Another way to write Javascript code.

Create external file (.js) extension.

Write Javascript code.
document.write('welcome');

suppose save this file with name myjsfile.js

HTML Code to use external file

<html>
<head>
<title>my first Javascript code</title>
<script language="javascript" src="myjsfile.js">
</script>
</head>
<body>
</body>
</html>

This way is very useful when we want to use same javascript code to many pages.

Note: Javascript is a Case Senstive language.

Output in Javascript.

1-document.write() is used to print output.
document.write('welcome');
2- alert popup is used to print output.
alert('welcome');
3- Use HTML tag to print output.
Like <div>,<b> etc.
(We discuss output through HTML tag in later section).

Input in Javascript.

1-prompt popup is used to input any value.
prompt("Enter Number","0");
2- Use HTML tag to input value.
<input name="num" type="text" />


Next