All that you need to get started with creating JavaScript code for web applications is a simple text editor, such as Windows NotePad, or one of the many slightly more advanced text editors that provide line numbering, search and replace, and so on. An alternative is a proper HTML editor; you'll need one that allows you to edit the HTML source code, because that's where you need to add your JavaScript. A number of very good tools specifically aimed at developing web-based applications, such as Macromedia's excellent Dreamweaver MX, are also available. However, in this book we'll be concentrating on JavaScript, rather than any specific development tool. When it comes to learning the basics, it's often best to write the code by hand rather than relying on a tool to do it for you. This helps you to understand the fundamentals of the language before you attempt the more advanced logic that is beyond a tool's capability. Once you have a good understanding of the basics, you can use tools as timesavers so that you can spend more time on the more advanced and more interesting coding.
You'll also need a browser to view your web pages in. It's best to develop your JavaScript code on the sort of browsers you expect visitors to use to access your website. We'll see later in the chapter that there are different versions of JavaScript, each supported by different versions of the web browsers. Each of these JavaScript versions, while having a common core, also contains various extensions to the language. All the examples that we give in this book have been tested on Netscape Navigator versions 4.0, 4.7, 6, and 7, and Internet Explorer versions 4.0 to 6.0. Wherever a piece of code does not work on any of these browsers, a note to this effect has been made in the text. (In case you're wondering, Netscape Navigator 5 never made it out on general release to the public.) Even if your browser supports JavaScript, it is possible to disable this functionality in the browser. So, before we start on our first JavaScript examples in the next section, you should check whether JavaScript is enabled in your browser.
To do this in Netscape Navigator, choose Preferences from the Edit menu on the browser. In the window that appears, click the Advanced tab or item from the list. In Netscape 7 you need to click on Scripts and plug-ins, and check that the checkbox beside Enable JavaScript for Navigator is checked. If not, then check it. You can also change what JavaScript code is permitted to do; for example, you can modify the code to permit JavaScript to open new browser windows.
It is harder to turn off scripting in Internet Explorer. Choose Internet Options from the Tools menu on the browser, click the Security tab, and check whether the Internet or Local intranet options have custom security settings. If either of them do, click the Custom Level button, and scroll down to the Scripting section. Check that Active Scripting is set to Enable.
A final point to note is how to open our code examples in your browser. For most of the book, you simply need to open the file from where it is stored on your hard drive. You can do this in a number of ways. One way in Internet Explorer is to choose Open from the File menu, and click the Browse button to browse to where you stored the code. Similarly, in Netscape Navigator choose Open Page from the File menu, and click the Choose File button; in Netscape Navigator 6, choose Open File from the File menu.