Untitled Document



 Introduction to HTML
 Structure of HTML
 Creating First HTML  Document
 Building Your HTML  Document
 Tables
 Frames
 Including Images into  Document
 Including Multimedia
 Developing HTML  FORMS
 Using Style Sheet
 Understanding URLs
 Using JavaScript
 Introducing JavaScript
   Using JavaScript
 Introducing to  JavaScript
   What is JavaScript?
 Why should you use  Java Script?
 Structure of a  JavaScript
   Syntax of JavaScript
 JavaScript
 Statements
 
 Statements
 Blocks
 
 Blocks
 Comments
 
   Comments
 Single-Line  Comments
 Multiline Comments
 Data
 
   Data
   Strings
   Numbers
   Boolean
 Null
 Expressions
 
   Expressions
   Numeric Expressions
 Logical Expressions
 Variables
 
   Variables
 Defining and Naming  Variables
 Changing the Value  of a Variable
 Functions
 
   Functions
   Built-in Functions
 User-Defined  Functions
 Returning Values  from Function
 Flow Control
 
   Flow Control
   If and if ....else
   If Statement
   If...else Statement
   IF Statement
   Looping Statements
   For Loops
   While Loops
   WHILE Statement
   Switch Statement
   Break Statement
 Continue Statement
 Objects
 
   Objects
   Methods
   Properties
   Built-in Objects
 User-defined Objects
 Arrays
 
 Arrays
 Event Handlers
 
   Event Handlers
 onMouseOver,  onMouseOut Events
 onClick, onChange  Events Handlers
 Using the onSubmit  Event Handler
 Introduction to Cookies
 
 Introduction to  Cookies
   Sessions Cookies
 Persistent Cookies
 Using Java

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.




  Using JavaScript > Introducing JavaScript

  Using JavaScript

Introducing to JavaScript
Statements
Blocks
Comments
Data
Expressions
Variables
Functions
Flow control
Objects
Arrays
Event Handlers
Introduction to Cookies

  Introducing to JavaScript

  What is 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 <! -- comment -- > , 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.

  Syntax of JavaScript

<HTML>
<HEAD>
<SCRIPT LANGUAGE = "JavaScript">
<! --Use the start of a comment tag to hide the JavaScript code
// Your JavaScript code goes here
// close the comment tag on the line immediately before the </script> tag -- >

</SCRIPT>
</HEAD>
<BODY>
Your Web document goes here.
</BODY>
</HTML>

  JavaScript

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.

Back Next


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.




17, Vadsarvala Nivas, 65-A, J. Nehru Road, Mulund (W), Mumbai - 400 080 INDIA
Tel : 91-22-25795588, 91-22-25780444 Fax : 91-22-25793397
Email : ionline@vsnl.com
© Image Online 2001-2003