Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Perl CGl Programming: No experience required.
(Publisher: Sybex, Inc.)
Author(s): Erik Strom
ISBN: 0782121578
Publication Date: 11/01/97

Bookmark It

Search this book:
 
Previous Table of Contents Next


Using the Netscape Extensions

The most important and interesting of the Netscape extensions are the elements that deal with frames and applets, which is a word coined to describe little programs. The other extensions can be useful, but they don’t do nearly as much as frames and applets do. In fact, the BLINK element can be misused so easily that you’re probably better off not using it at all. Problems arise if you forget to end the blinking block with </BLINK>—your visitors will be horrified to find your entire Web page flashing merrily at them.

HTML frames have become so common on the World Wide Web that Webmasters must be assuming their visitors are using browsers that can handle them. Frames provide an interesting tool for Web development because they allow versatility in a page that plain-vanilla HTML simply isn’t able to. Plus, as you learned in Skill 5, because the documents comprising the framed Web page are specified with URLs, you can automatically launch a CGI application from the frame command.

If you are unfamiliar with how frames are constructed, a short example will make things clearer for you. It will take three HTML files, as follows:

   <HTML>

   <HEAD>
   <TITLE>Testing HTML frames</TITLE>
   </HEAD>

   <FRAMESET COLS="20%, 80%">
       <FRAME NAME="left" SCROLLING="NO" SRC="leftside.html">
       <FRAME NAME="right" SRC="rightside.html">
   </FRAMESET>

   </HTML>

Save this one as frame.html, then enter the next one:

   <HTML>

   <HEAD>
   <TITLE>Left side frame</TITLE>
   </HEAD>

   <BODY>
   <H2 ALIGN="CENTER">This is the left side frame</H2>
   </BODY>
   </HTML>

Call this file leftside.html. The next one looks like this:

   <HTML>

   <HEAD>
   <TITLE>Right side frame</TITLE>

   <BODY>
   <H2 ALIGN="CENTER">This is the right side frame</H2>

   </BODY>
   </HTML>

Save this file as rightside.html. Make sure all three files are in the same directory, or install them in your Web server’s default document directory. You can open frame.html directly from your browser or invoke it as a URL; in any event, frame.html is where the action starts. You should see something similar to the illustration in Figure 10.4.


Figure 10.4:  A simple framed page with two windows

Examining the Frame Structure

Frames are useful if you want to keep a static index or some other unmoveable information on part of a Web page, where the other parts can scroll and grow as they need to. In the frame example we’ve just put together, the left side will not scroll, while the right side will.

The key to running a framed page is the main file—frame.html in the example—which, through the <FRAMESET> declaration, calls in the left- and right-side pages. Notice the declaration:

   <FRAMESET COLS="20%, 80%">
       <FRAME NAME="left" SCROLLING="NO"   SRC="leftside.html">
       <FRAME NAME="right"   SRC="rightside.html">
   </FRAMESET>

The <FRAMESET> element in this example calls for two columns, the first taking up 20 percent of the screen and the second taking up the remaining 80 percent. The two windows could have been made into rows by using the ROWS= tag instead. Next, the frames themselves are defined with the <FRAME> tag. The NAME tag allows you to write HTML code that puts documents in the named window.

The file names of the HTML documents that draw the left and right windows are specified in the SRC tags and that’s how the windows are displayed.

A final thing to remember about setting up frames is that the FRAMESET element stands by itself in the document. If you accidentally enclose it in a BODY element, which is quite possible if you use software that automatically generates HTML, your frames won’t show up.

Using Netscape Applets

The APPLET element includes an inline program in your HTML page and runs it. It is only capable of running Java applets at present, but Netscape and other developers would like the APPLET element to be able to run any program, subject to security considerations, of course.


TIP:  Java applets are run by a Java interpreter that is built into the Web browser. It is possible to compile Java programs, but you can’t run those from the APPLET element of HTML.

Running a Java applet from the Web page is fairly straightforward. Here’s a snippet of HTML code that calls an applet:

   <APPLET CODE="AJavaClass.class" WIDTH=450 HEIGHT=500>
       <PARAM NAME="stuff" VALUE=450>
       <PARAM NAME="nonsense" VALUE="Stuff and nonsense">
   </APPLET>

This code loads the Java file AJavaClass.class into the browser’s Java interpreter, opens a 450- by 500-pixel window in the browser’s main window and runs the applet in it, passing parameters named stuff and nonsense to the Java program, which will do with them as it sees fit.


EXERCISE:  The Sambar Server: Building Your Web Site

This skill provided you with background on the Hypertext Markup Language and how it was created. You also learned about some of the extensions to HTML that you can add to your Web site. Try your hand at these:

  Rewrite your home page on the Sambar server to include frames.
  As in the example presented in this skill, make the left frame non-scrollable and place links to the other pages in your site there.
  Use the right frame for displaying each of the pages.

Moving On

You digressed a bit from Perl and CGI in this skill to learn about how the language of the World Wide Web was created, and about some of the enhancements that have been made to HTML over the years.

In Skill 11, you’ll learn about the platforms of the World Wide Web, the computers and operating systems that can be used to build a Web site.

You’ll cover the three most popular operating systems—UNIX, Windows NT, and Windows 95—in a bit more detail.

Are You Experienced?

Now you can…

  understand the difference between descriptive and procedural markup languages
  see how SGML was used to specify a language for the World Wide Web: HTML
  understand the Netscape extensions to the HTML 2.0 standard
  use the extensions to add more power to your Web site


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.