What is Javascript?
Javascript is programming language created by Brendan Eich for a company called Netscape. It quickly became very popular as it allowed web developers to manipulate the browser and its contents in ways that was not possible with ordinary HTML or Cascading Style Sheets. By using Javascript in your web pages, you can gain more control of how the page looks and behaves: document elements can be inspected, form elements validated before the contents are sent, browser details checked, cookies set, dates and times can be added to the page, even simple games can be added to a web page - all with a scripting language.
The learning curve for scripting is a lot 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.
All the scripts in these pages have been tested with modern version of Internet Explorer, Firefox, Safari, Chrome, and Opera. If you're ready, then, let's make a start.
Knowledge and Software
For this Javascript course, we're going to assume that you know some HTML. You by no means need to be a web design guru, but you should have some basic knowledge of how a web page is created. You should know about things like the HEAD and BODY section of a HTML page, how to create new paragraphs, insert images and hyperlinks. If not, then the place to start is our web design course, which is here:
The software we will use is just a basic text editor. This will be Notepad on a Windows computer for us, but you can use any operating system. For Mac users, the equivalent to Notepad is TextEdit. Another good free editor for the Mac is TextWrangler. You can get a copy here:
For Linux users, you will have a wide range of choices. There's a Wikipedia article here about text editors available to you:
For Windows users, one of the best free editors for basic programming is Notepad++. You can download a copy here:
For all users, we have a couple of templates you can use to make life easier. They are explained in the next section.
As for web browsers, you can use any one you like, but most of our examples are from Firefox. It's a good idea to test your code in more than one browser, however. Most of them are free, so it's just a question of downloading and installing them!.
Useful Javascript Templates for this Course
When you click a link above, a file will open in a new tab or window. The file will be a text file. Now clickFile > Save Page As, if you're using Firefox:
In the Chrome browser, simply right click the page and you'll see a menu appear. Click Save As from the options:
Create a Web Page from your Template
To turn your template into a HTML page, open the text file using Windows Explorer or Finder on the Mac:To get at the code for editing, open an Explorer or Finder window again. Right click the HTML page you want to edit. You should see an Open with option on the menu:
Here are the templates again:
In the next part, we'll take a look at something called debugging.