navigation
Thomas Brunt's OutFront Hosting
 
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Microsoft MVP
 

Creating JavaScript Rollover Buttons - Part III
FrontPage Newsletter Article July 2002

Putting the Code in Your Pages

First take the entire code in the text area, copy it into a Notepad file and save it. 

Before doing anything with the code you have made fire up a new page in FrontPage and take a look in html view. 

You will see that there are tags there delineating the head section of the page (<head></head>) and the body section (<body></body>). 

Now, open your Notepad file and paste the part of the code that looks like this into the <head></head> section.:

---------------------------------
<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin

image1 = new Image();
image1.src = "images/nav1_on.gif";

image2 = new Image();
image2.src = "images/nav2_on.gif";

// End -->
</script>

----------------------------------


You will have more buttons than that, but it is important that you paste everything from <SCRIPT LANGUAGE="JavaScript"> to </script> into the head section of your page.

Now take the bit that looks like this after the <body> tag: 

---------------------------------
<a href="index.htm" onmouseover="image1.src='images/nav1_on.gif';"
onmouseout="image1.src='images/nav1_off.gif';">
<img name="image1" src="images/nav1_off.gif" border=0></a>

<a href="folder/file.htm" onmouseover="image2.src='images/nav2_on.gif';"
onmouseout="image2.src='images/nav2_off.gif';">
<img name="image2" src="images/nav2_off.gif" border=0></a> 

etc for all your buttons
-------------------------------------

If you go to normal view you will find that your buttons are lined up side by side instead of one beneath the other. Simply position them correctly in normal view by using Shift+Return between each one to move them to new lines.

Now preview your page - if all has gone well you have rollover buttons!!

Your buttons are now in splendid isolation on the page, but you can just paste that HTML into a table cell to position it as you wish in your page layout. 

Not working?

The most common reason for this is that you did not enter the paths to the images correctly.

If the page you are working on is in the same folder as your index page then the path to each image will be in the format:

images/nav1_off.gif

If your page is in a subfolder you will need to edit the paths to read:

../images/nav1_off.gif

Another common reason for things not to work is a misspelling in some of the information you entered in the form. I once spent a long time trying to figure out why one button would not work only to eventually realize that I had, when I entered it, spelt 'images' as 'inages'. The script was looking in vain for a folder called 'inages'. 

Thinking about paths brings up another issue - how will the menu work in subdirectories and folders within your site?

>> Part IV: Making it Work Throughout Your Site 

<< Part II: Creating the JavaScript


 

Fun With Background Images
Fun With Bulleted Lists
Are You Compliant?
Introduction To Cascading Style Sheets
Creating Custom Error Pages
Designing Fast Loading Sites
Creating Funky Forms With CSS
htaccess Magic
An Introduction To JavaScript
JavaScript Snippets
Getting More From Mailto
Installing And Using Perl Scripts
Preparing Photos For Your Web Site
The Popup Dilemma
Paint Shop Pro Album 4
Creating And Using robots.txt File
Creating JavaScript Rollover Buttons
 

Microsoft Corporation in no way endorses or is affiliated with "OutFront." 
OutFront is published and edited by Thomas Brunt
440 Great Circle Dr., St. Matthews, SC 29135.  803-655-6151
© 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 All Rights Reserved
Click here to view our privacy statement.