Chapter 3: Using Java on Your Pages

index | previous | next  
 
 
 
Listing 3.2 Always be sure to display a message for non-Java-enabled browsers.

code listing
<HTML>
<HEAD>
  <TITLE>Hey, it's Java<TITLE>
</HEAD>
<BODY BGCOLOR=WHITE>
  <APPLET CODEBASE="classes"
  -> CODE="HelloWorld.class" WIDTH=200 HEIGHT=50>
    <H1>If you had Java, you'd be seeing a cool
  -> applet now</H1>
  </APPLET>
</BODY>
</HTML>


Figure 3.02
 
Fig. 3.2  Let people know that they should upgrade and find out what they're missing.
 
 
Figure 3.03
 
Fig. 3.3  If you don't have Java enabled, you can't see the cool Java effects.
 
 

Displaying a message for non-Java browsers

While most browsers these days have Java, some people use old browsers, and some surf the Web with Java turned off. In these cases, you should display a message letting people know what cool thing they're missing, as demonstrated in Listing 3.2.

To display a message for browsers without Java:

1. <H1>If you had Java, you'd be seeing a cool applet now</H1>

You might think that this looks just like normal HTML, and you'd be correct - it is. However, because it's within the APPLET tag, it's only shown when the user can't display the Java applet. Figure 3.2 shows how this displays on the screen.

red check Tips

In Figure 3.2, you might notice that the no Java message isn't in the same area that's set aside for the Java applet. Because the browser doesn't understand Java, it doesn't know about the HEIGHT and WIDTH attributes in the APPLET tag. Be sure to keep this in mind when laying out your pages.

Any HTML tags can go into this area. Be creative, but also be careful about closing any tags you open.


To enable Java in your browser:

Some browsers, such as Netscape 4, allow Java to be disabled. If Java has been disabled in your browser, you'll want to enable it so you can see Java in action. Figure 3.3 shows Netscape's Advanced preferences, which include a check box to enable or disable Java.