Jun 11
26
The Evolution Of Java Script
JavaScript was released by Netscape and Sun Microsystems in 1995. However, JavaScript is not the same thing as Java.
What is JavaScript
• It is a programming language.
• It is an interpreted language.
• It is object-based programming.
• It is widely used and supported
• It is accessible to the beginner.
Uses of JavaScript
• Use it to add multimedia elements .With JavaScript you can show, hide, change, resize images, and create image rollovers. You can create scrolling text across the status bar.
• Create pages dynamically .Based on the user’s choices, the date, or other external data, JavaScript can produce pages that are customized to the user.
• Interact with the user .It can do some processing of forms and can validate user input when the user submits the form.
Writing JavaScript
JavaScript code is typically embedded in the HTML, to be interpreted and run by the client’s browser. Here are some tips to remember when writing
JavaScript commands.
• JavaScript code is case sensitive
• White space between words and tabs are ignored
• Line breaks are ignored except within a statement
• JavaScript statements end with a semi- colon;
The SCRIPT Tag
The <SCRIPT> tag alerts a browser that JavaScript code follows. It is typically embedded in the HTML.
<SCRIPT language = “JavaScript”>
statements
</SCRIPT>
SCRIPT Example
• Open “script_tag.html” in a browser.
• View the Source
• Put the cursor after <! – Enter code below Æ and enter the following:
<SCRIPT language = “JavaScript”>
alert(“Welcome to the script tag test page.”)
</SCRIPT> 5
• Save the changes by choosing Save from the File menu.
• Then Refresh the browser by clicking the Refresh or Reload button.
Implementing JavaScript
There are three ways to add JavaScript commands to your Web Pages.
• Embedding code
• Inline code
• External file
External File
You can use the SRC attribute of the <SCRIPT> tag to call Java Script code from an external text file. This is useful if you have a lot of code or you want to run it from several pages, because any number of
pages can call the same external JavaScript file. The text file itself contains no HTML tags. It is call by the following tag:
<SCRIPT SRC=”filename.js”>
</SCRIPT>
External Example
• Open “external.html” in a browser
• View the Source
• Put the cursor after <! – Enter code here Æ and enter:
<SCRIPT language = “JavaScript” SRC = “external.js”>
</SCRIPT>
• Save the changes and Refresh the browser.
These are the basic ailments of the java script. We can have variables, functions, objects, and another kind of objects known as the document objects. The Document object represents the Web page that
is loaded in the browser window, and the content displayed on that page, including text and form elements. You can use the methods of the document object to work on a Web page. Here are the most common document methods:
• write() - write a string to the Web page
• open() - opens a new document
• close() - closes the document








