In This Chapter
Putting It All Together
[ic:check]Hello World? Every discipline has its traditions, and
programming is no exception. One
long-standing ritual found in almost every introductory book on any computer programming language
is to have the first program be one that displays the phrase "Hello World" on the screen.
The Basic Template
Hello World 1
[ic:check]Run Script, Run
HTML document into the Web browser.
If you've created the script file on the same computer on which the browser is installed, you will load a
"local file." Do this opening the File menu and choosing an option named something like Open file or
Open local file.
When you fire up Netscape Navigator and run this script, you should get something like what you see in the next figure.
Note that, in the previous example, you're using a Submit button (as defined by the <INPUT> tag attribute TYPE="submit"). The Submit button also generates an onSubmit event, which you could have used to equal effectiveness as the onClick event in this case. However, the onSubmit event handler is defined in the <FORM> tag not the <INPUT> tag. You can check this out for yourself by replacing the previous example with the following one, which will yield the exact same results:
Hello World 2
Okay, so your first little example wasn't all that elaborate. Well, you have to start somewhere! Now you’re ready to deviate from your template a little and look at a more significantly useful way to place text on the screen. Now you will generate new messages directly into the on-screen document.
A New Spin
Please click on the desired spice below:
The following two figures illustrate what the user would see when interacting with the this program.
Here, the salivating user can select which spice to learn more about.
This is HTML for a hyperlink and will momentarily be output to the browser window.
The second statement line constructs a similar link for the history of trading. This is followed by three document.write() statements, which simply output all of this HTML to the browser window, as shown in the previous figure.
If you've done a bit of Web surfing, no doubt you've encountered many pages that have links "for text-based browsers" or "for non-Netscape browsers." Because there are several "standards" on the Web today, not all browsers can handle all things. Thoughtful Web authors try to accommodate this by creating different collections of pages that are tailored to different types of browsers.
But, if you don't have <A HREF="http://home.netscape.com/">Netscape
Navigator</A> or <A HREF=”http://www.microsoft.com/ie/default.asp”>Microsoft Internet Explorer</A>, you won't be able to see any of the fun!
The Least You Need to Know
Clarify Your Marks
Note that when you have to use double quotation marks for something
else in the display line
(such as an URL), you can use single quotation marks to bracket the entire display string. Or you can use
double quotation marks to bracket the entire string and single quotation marks within it. Either way works,
as long as you are consistent: If you start the string with a double quotation mark, be sure to bracket the end
of the string with a double quotation mark and use single quotation marks when necessary w
ithin. (And vice versa.)
For comments or technical support for our books and software, select Talk to Us. © 1997, QUE Corporation, an imprint of Macmillan Publishing USA, a Simon & Schuster Company.
To order books, call us at 800-716-0044 or 317-228-4366.
© 1997, QUE Corporation, an imprint of Macmillan Publishing USA, a Simon & Schuster Company.