Make your own free website on Tripod.com
logo.gif

Embedding Java Applets and Javascript

Java is a language that allows Java programmers to write small programs called Applets that you can download and use on your web page. JavaFile.Com has a great selection of applets you can try.

Applets can add special effects to your page, aid navigation, alter images or just spruce up some text. When a visitor loads your web page with a Java Applet on it, the visitor's browser downloads the Applet from your server and then runs it from their own computer.

Javascript is a scripting language you can add directly to your page coding. There are no other elements to upload to your server. Javascript allows you to add many extra functions and effects to your pages. JavaFile.Com also has a wide range of Javascripts for you to use.

The Java Applet

Java Applet's use .class files to contain the programming instructions they need. Some Applets will use only one .class file, some will use several. You must upload all of the associated .class files into your web page directory.

There are 3 steps usually needed to add an applet to your page:

  1. Add the applet HTML coding onto your web page
  2. Edit any Param Values as outlined by the Applet's Author
  3. Upload all of the associated files (.class files, images, sounds and .html) to your web server directory
To embed an Applet on your web page use the <APPLET> Tag. Change the applet's parameters by editing the VALUE= settings in the <PARAM> Tag(s).

Here is an example applet and it's coding:

 This is the Applet's HTML code for your page:  The Java Applet: 
<APPLET CODE="Shaking.class" WIDTH="104" HEIGHT="130">
<PARAM NAME="amplitude" VALUE="4">
<PARAM NAME="bgcolor" VALUE="#ffffff">
<PARAM NAME="picture" VALUE="picture.gif">
<PARAM NAME="shakespeed" VALUE="20">
<PARAM NAME="sound" VALUE="sound.au">
</APPLET>
     

In this example, some of the VALUE= settings can be modified by you to add your own pictures and sound files, or adjust the color of the applet's background to match your page. Be sure to read the documentation that comes with your applet and only change the Value's specified as editable.

This example Applet requires 3 files be uploaded to the web server:

  1. Shaking.class (the programming instructions)
  2. picture.gif (the image file you wish to use)
  3. sound.au (the sound file you wish to use)

TIP: Class files are case-sensitive, so be careful when you are uploading them to a server. A lot of servers will automatically change all filenames to lowercase so you may have to rename your .class files once you have uploaded them.

Adding Javascript

Javascript has quite a different method of installing, since you don't need to upload any separate elements like .class files and so forth.

There are 2 steps required to install a javascript on your page:

  1. Copy all the stuff between the <SCRIPT> and the </SCRIPT> tag, and paste it somewhere between your <HEAD> and </HEAD> tag.
  2. Copy and paste the HTML code that activates the javascript somewhere into the Body of your page

Try the example script we have below. Follow the steps and you should have no trouble:

  1. Copy and Paste this code between the <HEAD> and </HEAD> tags on your page:

    <script language="JavaScript">
    <!-- Hide the script from old browsers --
    function loadalert ()
    {alert("This is a standard javascript alertbox! Yee haa!")
    }
    // --End Hiding Here -->
    </script>

    The top of your page should now look something like this:

    <HTML>
    <HEAD>
    <script language="JavaScript">
    <!-- Hide the script from old browsers --
    function loadalert ()
    {alert("This is a standard javascript alertbox! Yee haa!")
    }
    // --End Hiding Here -->
    </script>

    </HEAD>

  2. Copy and Paste this HTML coding anywhere in the Body of your page:

<INPUT TYPE="submit" VALUE="Click Me To Activate The Script" onClick="loadalert()">

Now you should have a button like this:

Ok, so now try clicking your spiffy new javascript button! If you followed the steps correctly you should have a standard javascript alertbox on your page now.




Now that your pages are basically complete, you need to let the world know that your work is out there to see. The first step is to learn how to create Meta Tags:

~~~~~ On to "Meta Tags" ~~~~~