Javascript is used in all web applications directly or indirectly. That’s probably why it’s one of the most popular languages on the World Wide Web. Netscape created JavaScript in 1995.

  • JavaScript is the scripting language of the Web!
  • JavaScript is used in millions of Web pages to improve the design, validate forms, detect browsers, create cookies, and much more.
  • JavaScript is the most popular scripting language on the internet.
  • JavaScript is easy to learn!

JavaScript is a versatile language. It can be used to create menus, validate forms, provide interactive calendars, post the current day’s headlines, produce background effects on a Web page, track a visitor’s history on your site, and play games, among many other things. Originally called “LiveScript,” it was designed to make Web pages more interactive. In the beginning the language was plagued with security problems which, for the most part, have been overcome. The current version of JavaScript is 1.5.

Before we kickoff:

There are a few things you will need before we begin our study. One of them is a basic knowledge of HTML/XHTML. While you don’t need to be an expert, you will need to know the basics of using HTML elements and attributes. JavaScript can be used to dynamically create Web pages and a general knowledge of HTML is essential. A little knowledge of CSS won’t coz any problem

  • JavaScript is a scripting language (a scripting language is a lightweight programming language)
  • A JavaScript consists of lines of executable computer code
  • A JavaScript is usually embedded directly into HTML pages
  • JavaScript was designed to add interactivity to HTML pages
  • JavaScript is an interpreted language (means that scripts execute without preliminary compilation
READ  Javascript basics - Part 2

A Script is a segment of code that manipulates the browser and its contents in ways that is not possible with ordinary HTML or Cascading Style Sheets. By using a script in your web pages, you can gain more control of how the page looks and behaves: dates and times can be added to the page, form elements validated before the contents are sent, browser details checked, cookies set, even simple games can be added to a web page – all with a scripting language. The learning curve for scripting is a lot a steeper than HTML and Style Sheets. But you can learn the basics, and use scripts on your own pages, without it causing you too much trouble. The scripting language covered in these pages is meant to get you started on the subject, and is not intended as an in-depth study. We’re going to study the JavaScript programming language, because it is a widely-used scripting language for web pages. All the scripts in these pages have been tested with modern versions of a wide variety of browsers. If you’re ready, then, let’s make a start. First Script Let’s jump right in with a bit of code. Use any  HTML Editor of your choice .With your editor open, copy the following code. When you’re done copying it, save your work and load it into your browser.


<SCRIPT LANGUAGE = JavaScript> document.write(“Hello World”)</SCRIPT></BODY> </HTML>

All right, how did you get on? All that typing should have gotten you this in the browser: “Hello World” Granted, that’s a heck of a lot of trouble to go to just to write “Hello World”. But it’s a start. Let’s explain what’s going on. When you’re writing your scripts, you enclose them between two <SCRIPT> tags, an opening one and a closing one. The opening one should tell the browser what language the script is written in: <SCRIPT LANGUAGE = JavaScript> The closing Script tag is just the word SCRIPT in between two angle brackets with a forward slash: </SCRIPT> Most of your JavaScript will go between these two tags. So what’s all that “document dot write” bit? document.write(“Hello World”) Document is part of something called the Document Object Model. Document refers to all the text and HTML elements between the two BODY tags. And that includes any attributes inside the BODY tag itself. Like BGCOLOR. Write( ) is a method of Document. A method is a bit of code that actually does something. As opposed to a Property, which IS something. Methods are usually Verbs, and Properties usually Nouns. The Write( ) method writes text (and numbers as well) between the two BODY tags on your page. For all you English language experts out there who might be protesting about the lack of capital letters, Document is spelt with a lowercase “d”, and Write with a lowercase “w”. Try changing your code to this and see what happens:

READ  JavaScript Functions

Document.Write(“Hello World”) JavaScript is damned picky about capital letters – it doesn’t like them at all! The part or parts between the two brackets of write( ) are what will be written to your page. Direct text goes between two double quotes; Variables don’t need any. Whoops, we haven’t done variables yet. We’ll get to them. So the whole line reads “Write the text Hello World between the two BODY tags of the web page.”