Introduction to JavaScript

These notes are not aimed at professional programmers. I'm assuming that you've written some web sites and now need to add a little bit of interaction. You're not working in a large team and a site that works is more important than a site which meets all the latest software engineering standards. I'm going to start off by cutting corners and simplifying things as far as I can. My aim is to get you to the point where you can write a program that works. Then I'll give some links to sites that will take you further.

Think of it as learning to drive. When you begin to learn you are really happy if you can start and stop the car and drive across an empty car park without hitting anything. Understeer, oversteer and double declutching (ask your father) can come later.

As with learning to drive, you can't learn JavaScript by reading about it. You have to do it and that means writing your own programs. Please try all the examples and explore what will happen if you make changes to the programs. You can't hurt anything and you've got to experiment. None of your experiments will fail. Your modified programs might not run but if you can find out why they don't run then in terms of learning, that's a success.

HTML

I'm assuming that you can write a simple web page using HTML. If you are happy with this level of complexity:

<html>
  <!-- This is my first web page -->
  <head>
     <title> My first web page </title>
  </head>
  <body>
    This text will appear on the page.
  </body>
</html>

then you know enough HTML to be able to work through my pages here.

If the snippet of HTML quoted above is a mystery to you then I suspect you've been using some program where you design the layout of your page and it then generates the HTML automatically. I'm afraid you'll need to get closer to the code in order to be able to write JavaScript programs. It's not something that can be automated.

Actually, it can be automated but you can only then produce what the automatic program generator has been programmed to produce. You'll be very restricted.

What is JavaScript?

JavaScript is a scripting language which means that it cannot be used to write a stand- alone program. A JavaScript program can't run without some sort of assistance and you'll be running your programs inside a browser. The browser has an interpreter which reads the JavaScript program one line at a time and obeys the instructions one line at a time. This will be important later.

What JavaScript is not

Just to clear up a few matters that cause confusion:

  • JavaScript is not Java. Both are loosely based on the C language and both have names starting with the same four letters but these are the only connections between them.
  • JavaScript is not VBScript. Both run in a browser but VBScript won't run in browsers other than Internet Explorer. JavaSript will run in any recent browser.
  • JavaScript is not JScript. Both are based on the ECMAScript standard but JScript is Microsoft's interpretation and extension of the standard.

MS Access technical tips

Visual FoxPro technical tips

General Tips

 

More tips from Alvechurch Data

Search page for Alvechurch Data

Searching a web site with JavaScript

Read More

Site Map

Site map of the Alvechurch Data site

Read More

Javascript while loops

JavaScript do and while loops

Read More

Javascript for loops

Javascript for loops

Read More

Repetition in Javascript

JavaScript structures for repetition

Read More