- Creating Our First Script
- Dissecting Our First Script
- Viewing Script Errors
- Browser Object Properties, Methods, and Events
- Handling Cross-Browser Programming Issues
Creating Our First Script
Figure 1.1 Our first example script in Netscape Navigator.
Figure 1.2 Our first example script in Internet Explorer.
Choosing a Text Editor
Any text editor you want to use to create web pages will be fine herein fact, the less fancy the better. Your web pages have to be readable by web browsers as plain text, which means you must save them as plain text. Fancy word processors, such as Microsoft Word, do not save documents as plain text by default. You can still use them, but you must be sure to save your web pages as plain text documents. (In Microsoft Word, for example, save them using the .txt option in the Save As dialog box.)
A simpler text editor, such as WordPad in Windows or SimpleText in the Mac, is better. Make sure, however, that you're saving your documents in plain text format. (WordPad's default setting is rich text format, which won't work in browsersselect the Text Document format when you save your web pages using WordPad.) For example, you can see the first web page we'll create, first.html, in WordPad in Figure 1.3.
Figure 1.3 Creating a web page in WordPad.
Selecting a Browser
The browser you use is up to you, of course. In this book, we'll cover the various versions available for both the Internet Explorer and the Netscape Navigator. Both are available for free online (Netscape Navigator at http://browsers.netscape.com/browsers/main.tmpl; Internet Explorer at http://www.microsoft.com/ie/default.asp). If you're programming for the general public, you should know that the Internet Explorer has the overwhelming market share at this point. However, the Netscape Navigator still has a lot to offer.
Creating Your Programming Environment
That establishes our programming environment; now let's get to the web page itself.
If you are not comfortable with the level of HTML we'll be using here, take some time out and come up to speed on HTML. It won't take long, and will be well worth it for our work here.
Here, then, is how we start our first web page, first.html, making sure that the page's title and the heading text appear as it should:
<HTML> <HEAD> <TITLE>Our first script!</TITLE> </HEAD> <BODY> <H1>Here we go!</H1> </BODY> </HTML>
(Listing 01-01.html on the web site)
Now let's take a look at what we've done.