Frames
Meta Tags
Java and JavaScript
Hosting and Uploading


 

JAVA AND JAVASCRIPT

First and foremost, you should be aware that Java and JavaScript are completely different.

Java

Java is a programming language much like C++, the programming language that Microsoft Word is written in. Java is designed to make independently functioning programs. One of the nice things about Java is that it is platform independent. This comes in very handy when programming for the web, which is used by different machines running different operating systems on different browsers.

As in this web design course, you wont be programming in Java, but there may come a time that youll have to insert a java based program in your website.

Inserting a Java Based Program Into Your Site.

An "applet" is a program (application) that functions inside of another program. Java programs functioning inside of your browser are therefore referred to a "Java Applets". To insert a Java applet you need only stipulate the name of the applet, where it is kept, and its height and width. Some Java programs require parameters, optional settings that allow you to do things like change the applets background color. The following code is an example of how a java applet can be inserted into your web page:

<applet codebase="folder/applet/is/kept/in" code="applet_name.class" width=155 height=30>

          <param name=bgcolor value="orange">

          </applet>

***NOTE: You must be careful when inserting Java into your site, as the whole program is required to load before displaying. This can take some time.

JavaScript

Whereas Java is a programming language, JavaScript is a scripting language much like HTML. It goes directly into your web pages and does not require a different download. JavaScript is incredibly useful. Among many other things, JavaScript can be used to perform mathematical calculations, detect browser settings or plug-in availability, or make roll-over buttons and special menu items. It is not imperative that you know how to write JavaScript if you just want to use JavaScript. In fact, with a little practice, changing JavaScript to suit your needs is easy!

You can establish what's JavaScript and what's just plain HTML by looking at the tags. JavaScript will always begin with:

<script language="javascript">

and the sequence will end with:

</script>

The script can be placed anywhere inside your HTML code as long as it is enclosed within the proper tags. Protocol says, however, that it should be in the <head> of your HTML document.

Many wonderful scripts are available for free on the Internet. Lots of these come with good directions if modifications are necessary. Check out:

http://javascript.internet.com/

HTML generators are also very useful for generating JavaScripts. During the Dreamweaver section, we will place a good number of JavaScripts.

JavaScript Screen Resolution Detection and Re-Direct

The following is a script designed to detect a users screen resolution and send them to a page specifically created for that resolution. Simple place the script inside your website and change the marked sections:

Remember that JavaScript should (by convention) be placed in the head.

<script language="javascript">

//tmtC_resolutionRedirect

if (window.screen){

  var w = screen.width;

<!INSERT THE FILE PATH TO THE PAGE VIEWERS SHOULD SEE IF THEIR MONITOR IS SET TO 640 x 480 BELOW-

  tmt_url_640 = "640_page_here.htm";

<! INSERT THE FILE PATH TO THE PAGE VIEWERS SHOULD SEE IF THEIR MONITOR IS SET TO 800 x 600 BELOW-

  tmt_url_800 = "800_page_here.htm";

<! INSERT THE FILE PATH TO THE PAGE VIEWERS SHOULD SEE IF THEIR MONITOR IS SET TO 1024 x 768 (AND HIGHER) BELOW-

  tmt_url_1024 = "1024_page_here.htm";

  if(w<740){

    self.location.replace(tmt_url_640);

  }

  if(w>=740 & w<835){

    self.location.replace(tmt_url_800);

  }

  if(w>=835){

    self.location.replace(tmt_url_1024);

  }

}//tmtC_resolutionRedirectEnd

</script>

On to Hosting and Uploading |