wildepages.com for newbie web builders

Javascript - effects, tricks and problems

Javascript is a language used for making things happen on a web page. The most common uses you will encounter are Menus, forms and pop-up pages. Yes the same pop-up pages as plague the net with advertisements, however, including pop-ups within a web page is a useful method of including information that can be requested by the visitor. An example would be an online news-paper or instruction page that can be called up by your visitor and closed again without having to leave the page.

The actual writing of Javascript is not as straightforward as writing HTML as it involves defining and calling items or elements rather than typing words that will be shown on the web page. A few examples will make this a bit more obvious.

The first example is for producing a drop down menu that allows fast site navigation:

Place the first piece of code in the 'head' section of document. Javascript menu code - header information

This part of the script defines the function. The browser is informed that the following piece of text is 'JavaScript' and then names the function 'gothere(mname)'. The rest of the script is enclosed in the curly brackets ({ , }) defining the function.

It is important to remember that all the script within the curly brackets is actually one line and must not be broken. Lines are called Java statements and read continuously from bracket to bracket - breaking the statement will produce unpredictable results (usually nothing works!).

HTML code. Place anywhere in body section of document.
Javascript menu code - HTML body

This piece of code is the html to produce the image of the menu as a table and includes the go to addresses. In the example only one destination is listed, described as 'contents' with the address 'http://www.yoursite.com/index.html', whereas you would list all the pages in your site with their addresses by duplicating the 'OPTION' line with the additional addresses and descriptions. The Javascript in the head section of your page will interpret the details and does not need to be altered (in fact the Javascript in the head will run any and all menus on the page that you have created with Javascript Menu Master).

Javascript Menu Master is a free tool from Harmony Hollow Software. I have found that it is often quicker and far less fraught to generate Javascript code by using these sort of tools. Another such tool is Hot Wax Pro 2. Hot Wax will create and insert JavaScript's, adding extra functionality to your web site. Add Alerts, buttons, time and date functions, status bar scrollers as well as SPAM Solutions and Image mouseOver scripts (plus many more). The software includes syntax highlighting and fully automated insertion techniques that make the software accessible to both experts and novices.

Visiting sites that offer free script snippets also can save a lot of time and effort. An excellent site to visit is JavaScript Source where there is a vast selection of scripts that you can copy and paste into your web pages.

Another big use for Javascript is in creating pop-up information windows; These are especially useful when including some information elements in a page, but knowing that not all visitors will want to see it. Create an elective pop-up and those who want to see can, those who don't need not open the window.

Let me demonstrate with this full-page pop-up:


Contents Coding index page Exit Here Contact:

Created on November 9, 2002

copyright©2002 Wilde Pages Ltd.,
except for JavaScript's where authorship / ownership acknowledged.