PDA

View Full Version : Help with Java Script ( mouse Over ) action


shep
02-12-2005, 06:38 PM
Hello:

I have a small problem, and was hoping that someone who's good with Java can help. I have a small Java script that a friend wrote for me, that performs a mouse over action, so when people put there mouse on a different link, the button changes. Unfortunately, this only seems to work on the index.htm page, and none of the other pages? I copied the pages exactly, and the header is the same. I get a javascript error when I mouse over any other page except the index.htm. Anyone have any idea why? I've posted the script below. Any help would be appreciated.

Thanks

shep


<!--
//rollovers...

if(document.images) {


homeoff = new Image();
homeoff.src = "images/homeoff.gif";
homeover = new Image();
homeover.src = "images/homeover.gif";


aboutoff = new Image();
aboutoff.src = "images/aboutoff.gif";
aboutover = new Image();
aboutover.src = "images/aboutover.gif";


conoff = new Image();
conoff.src = "images/conoff.gif";
conover = new Image();
conover.src = "images/conover.gif";

prodoff = new Image();
prodoff.src = "images/prodoff.gif";
prodover = new Image();
prodover.src = "images/prodover.gif";

servoff = new Image();
servoff.src = "images/servoff.gif";
servover = new Image();
servover.src = "images/servover.gif";


}

function onoff(imgName,state) {
if(document.images) {
document.images[imgName].src = eval(imgName+state+".src");
}
}
//-->

Tim
02-12-2005, 06:47 PM
I'm not sure about this, but it might have to do with the location of the images relative to the location of your page. Are the two pages in the same directory?

shep
02-12-2005, 08:08 PM
Hey Tim:

Thanks for the reply. Yes all *.htm pages are in the same location, basically the root folder. the images are all in a /images directory, and the index.htm is the only file that actually get's the mouse over colors ( graphics) to appear? When I am on another page, I get a javascript error? Not too sure why.

thanks fro the reply.

shep

DwSoFt
02-17-2005, 01:09 AM
hey, im good at JS, but you said java, but what you are talking about is JS, so im confused tell me exactly whats wrong, and ill help

shep
02-17-2005, 08:31 PM
Sorry I meant to say JS, not Java. Can you see what is wrong with my mouse over butons? I thought they were all setup properly, but it doesn't work.

the site address is: www.smart7systems.com


Thanks very much

Shep

Anyone able to help with this JS problem? Thanks very much

Shep

40footsteps
02-20-2005, 01:36 AM
Originally posted by shep@Feb 20 2005, 06:16 AM
Anyone able to help with this JS problem? Thanks very much

Shep
28115


a little confused. check the "state". Remember that JS is case-sensitive. I hope I can help, reply if you're still having trouble.

688206002
02-20-2005, 02:37 AM
Originally posted by shep@Feb 17 2005, 03:31 PM
Sorry I meant to say JS, not Java. Can you see what is wrong with my mouse over butons? I thought they were all setup properly, but it doesn't work.

the site address is: www.smart7systems.com
Thanks very much

Shep

Anyone able to help with this JS problem? Thanks very much

Shep
27735


Shep, don't double post (I merged them for you). Use the edit button and read this: http://www.hostmatrix.org/forum/index.php?showtopic=2753

This is the official grace warning; it'll be warning levels from now on.


On a side note, here's a nice page that makes you mouseovers. The code isn't bad (as in, not very messy) but, most importantly, it works.
http://mavweb.net/mouseover-maker.asp

geek
02-20-2005, 03:18 AM
i use dreamweaver MX 04, if you have it you can go to insert -> image objects -> rollover image. Fill in 3 lines, and it writes the code for you, with the option have having it preload and all that jazz.

shep
02-20-2005, 01:21 PM
Thanks very much 688206002

That page is perfect! Sorry about th edouble post.

Shep