|
|
Introducing to JavaScript |
|
|
Statements |
|
|
Blocks |
|
|
Comments |
|
|
Data |
|
|
Expressions |
|
|
Variables |
|
|
Functions |
|
|
Flow control |
|
|
Objects |
|
|
Arrays |
|
|
Event Handlers |
|
|
Introduction to Cookies |
| Introducing to JavaScript |
JavaScript is a scripting language that
Netscape created, and it resembles Sun's Java language. JavaScript
is an easy-to-use object scripting language designed for creating
live online applications that link together objects and resources
on both clients and servers. JavaScript is designed for use
by HTML page authors and enterprise application developers
to dynamically script the behavior of objects running on either a client or server.
JavaScript is powerful enough to be truly
useful, even though it is not a full-fledged programming language.
JavaScript is simpler and less sophisticated than a "real"
programming language. It is supported by almost all popular browsers.
<SCRIPT LANGUAGE = "JavaScript">
..............................
.............................. .............................. </SCRIPT>
| Why should you use Java Script? |
The scripts written using JavaScript will
eventually be able to control all aspects of a Web page as
well as with compiled Java applets. Apart from such futuristic
possibilities, what JavaScript enables you to do now is perform
many simple programming tasks at the Web browser end of the
system, instead of relying on CGI scripts at the Web server
end. In addition, JavaScript reads on forms and other data entry screens.
| Structure of a JavaScript |
You should follow certain conventions while writing the JavaScript. They are as follows
|
|
As a rule, the <SCRIPT>
tag should be placed inside the <HEAD>
and </HEAD> tags at the
start of your document, not inside the <BODY>
tags. This tip is not a hard and fast requirement, but
it is a standard you should adopt whenever possible. Basically,
because the code for your scripts is not to be displayed
on the Web page itself, it should not be included in the
<BODY> section. Instead,
it should be included in the <HEAD>
section with all the other control and information tags
such as <TITLE> and <META>. |
|
|
Because Web browsers that
are not JavaScript aware will attempt to treat your JavaScript
code as part of the contents of your Web page, surrounding
your entire JavaScript code with a <! -- comment tag
-- > is vitally important. Doing so will ensure that
non-JavaScript aware browsers can at least display your
page correctly, if not make it work properly. |
|
|
Unlike HTML, which uses
the
, comments inside JavaScript code use the // symbol at
the start of a line. Any line of JavaScript code that
starts with this symbol will be treated as a comment and ignored. |
|
|
JavaScript is a case sensitive language. |
<HTML> <HEAD>
<SCRIPT LANGUAGE = "JavaScript">
</SCRIPT>
</HEAD> <BODY>
Your Web document goes here.
</BODY> </HTML>
In this Exercise, you will learn how to use Script tag.
The SCRIPT tag denotes the begining of JavaScript
code. LANGUAGE attribute is to declare the scripting language to be used (like JavaScript or LiveScript).
The write method of the document object
displays its argument (the string "Sample JavaScript Program") in the Navigator.
The title method of the document object displays the title of the current Web page.
The SCRIPT tag denotes the end of JavaScript code.


Copyrights : Layout Galaxy All Rights Reserved
No part of this tutorial may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, electrostatic, magnetic tape, mechanical or otherwise, without prior permission in writing from Layout Galaxy.
|
|
|