|[ LiB ]|
Here are your available options:
In this example, you will create the classic "Hello World" script that every programming book since the beginning of time has used as its introductory example. After all, who am I to defy such an honored tradition?
Most JScript programmers have a script editor that they always work with. Modern script editors provide a number of features that facilitate and expedite script development, making them a lot more useful than Notepad. For example, most script editors will provide statement color coding. In addition, they can be configured to indent script statements automatically. Script editors may also provide wizards or templates that assist in the creation of new scripts. Some editors will even let you test your scripts from directly within the editor, saving you the trouble of having to load your HTML pages into your Web browser each time you want to test them. For example, HomeSite is a very popular editor among Web developers and can also be used when developing JScripts. To learn more about HomeSite, check out its home page at http://www.macromedia.com/software/ homesite .
<HTML> <HEAD> <TITLE>Script 1.1 - Insert Descriptive Title Here</TITLE> </HEAD> <BODY> </BODY> </HTML>
As you can see, my template contains the <HEAD> </HEAD> , <TITLE> </TITLE> , and <BODY> </BODY> tag sets all wrapped inside the starting and ending <HTML> </HTML> tag set. If you want to do so, create your own template now. When you are done, add the following lines inside the body section:
Now that you have typed in your first script, you need to save it. I called my script HelloWorld.html. The HTML extension identifies the page as an HTML page. Your computer uses the information in the file's extension to associate the file with a particular application. An .html extension tells the operating system to open its default browser and pass the HTML file to it. Alternatively, you can use the .htm extension, which is also recognized as an extension for HTML pages.
If you are using a full-featured HTML editor, the editor may enable you to test your script with the click of a button. Because Notepad has no such automatic HTML testing feature, I simply started up a browser and used it to open the HelloWorld.html file. The browser opened my page and ran the script.
Depending on the browser installed on your computer, the process of testing your script is slightly different as outlined in the following procedures.
Testing with Netscape Communicator:
Start Netscape Navigator.
In the menu bar, click on File and then click on Open Web Location.
Type the location of your HTML page and click on Open . Alternatively, click on the Choose File button to browse and find the HTML page and then select it and then click on Open. Netscape Navigator opens the page as shown in Figure 1.4.
Testing with Internet Explorer:
Start Internet Explorer.
In the Internet Explorer menu bar, click on File and then click on Open. The Open dialog box appears.
Type the location of your HTML page and click on OK. Alternatively, click on the Browse button, locate and select your HTML file and then click on OK. Internet Explorer opens the page as shown in Figure 1.5.
After loading your new script and making sure that it works the way that you intended in both Netscape Navigator and Internet Explorer, you know that you probably have a good script. However, both Internet Explorer and Netscape Communicator do a really good job of hiding errors when they occur. I will show you how to look for and fix these errors on Sunday morning. If you did not see the Hello World message displayed, then you probably mistyped something, so go back and reopen your HTML page and double-check your work. For now, I'll assume that you saw what you expected when you loaded your Web page and everything is okay.
|[ LiB ]|