Hi, I'm looking for help with a function. I'm new to javascript, and I can't figure out what to do.
On my website, I have a function that calls for an image swap for each button on the menu. Now I'd like to add an onClick image swap function - how do I do that?
Here's the function:
(head:)
var revert = new Array();
var inames = new Array('navh-home', 'navh-realms', 'navh-cast', 'navh-archives', 'navh-rules', 'navh-game');
if (document.images) { // Preload
var flipped = new Array();
for(i=0; i< inames.length; i++) {
flipped[i] = new Image();
flipped[i].src= "KFR0 images/buts/"+inames[i]+"2.gif";
}
}
function over(num) {
if(document.images) {
revert[num]=document.images[inames[num]] .src;
document.images[inames[num]].src= flipped[num].src;
}
}
function out(num) {
if(document.images) document.images[inames[num]].src= revert[num];
}
(body example:)
img src="KFR0 images/buts/navh-game1.gif" border=0 alt="Local information" name="navh-game" onMouseOver="over(5)" onMouseOut="out(5)">
I'd really appreciate any help!
On my website, I have a function that calls for an image swap for each button on the menu. Now I'd like to add an onClick image swap function - how do I do that?
Here's the function:
(head:)
var revert = new Array();
var inames = new Array('navh-home', 'navh-realms', 'navh-cast', 'navh-archives', 'navh-rules', 'navh-game');
if (document.images) { // Preload
var flipped = new Array();
for(i=0; i< inames.length; i++) {
flipped[i] = new Image();
flipped[i].src= "KFR0 images/buts/"+inames[i]+"2.gif";
}
}
function over(num) {
if(document.images) {
revert[num]=document.images[inames[num]]
document.images[inames[num]].src= flipped[num].src;
}
}
function out(num) {
if(document.images) document.images[inames[num]].src= revert[num];
}
(body example:)
img src="KFR0 images/buts/navh-game1.gif" border=0 alt="Local information" name="navh-game" onMouseOver="over(5)" onMouseOut="out(5)">
I'd really appreciate any help!
