JavaScript Introduction

JavaScript is Netscapes cross platform object based scripting language for client and server applications.

JavaScript Features

  • JavaScript is an easy to use language
  • JavaScript is not a form of Java
  • JavaScript is a Object based language and is not compiled and is a purely interpreted language
  • Script is embedded directly into the HTML pages and interpreted by the browser at runtime
  • JavaScript is a lightweight, interpreted programming language
  • Designed for creating network-centric applications
  • Complementary to and integrated with Java
  • Complementary to and integrated with HTML
  • Open and cross-platform

Javascript Tag

A JavaScript consists of JavaScript statements that are placed within the <script>... </script> HTML tags in a web page. You can place the <script> tag containing your JavaScript anywhere within your web page and keep it within the <head> tags. The <script> tag alert the browser program to begin interpreting all the text between these tags as a script.

Script Tag Attributes

  • Language: This attribute specifies what scripting language we are using. Basically, its value will be javascript.
  • Type: This attribute is to indicate the scripting language in use and its value should be set to "text/javascript".

JavaScript statement will look like

<script language="Javascript">
 JavaScript statements.....

This is the most common way of using JavaScript on HTML pages.

How to use JavaScript file in HTML code

<title>My first Javascript code</title>
<Script SRC="myCode.js">

JavaScript Epression

The expression is preceded by an & and followed by ; and enclosed in curly braces {}


Here myTitle is a JavaScript variable.

Event Handlers in some HTML tags

<title>My first Javascript code</title>
<INPUT TYPE = "button" VALUE="click" 

Javascript allows more than one statement which can be included by separating with a semicolon ";"