Hey all,
I made this gallery with the ability to go through the images with the arrow keys.
The problem is it only works with mozilla (as far as i can tell). I dont understand why…
I am using onKeyPress to handle the key input, and event.keyCode to gather the key pressed. All the rest of function have nothing specail.
The gallery is a photoshop based gallery that i modded. Theres two places in which there is javascript, the main page, and the thumbnail bar. All the thumbnail bar does is send some varibals to the main page. heres the code for the thumbnail bar, which is invoked with a onLoad:
function getTd() {
//counts the amount of pictures
var tds = self.document.getElementsByTagName("td")
var nameString ="%FILENAME%";
//splits the filename string to get the base name and the number length
var newString = String(nameString).split("_");
parent.setThem(tds.length, newString[0], newString[1].split(".")[0]);
}
and heres the code on the main page:
//main image counter
var counter = 0;
var next;
var holder = new Array();
//creates a base path to work with for loading the pictures
var base_path = self.location.toString()
if(base_path.indexOf("/index.")) {
base_path = base_path.split("index.")[0];
}
base_path+="pages/";
//sets all the main vars
//The info comes from the thumbnail page
function setThem(numofimages, basename, numberlength) {
holder[0] = numofimages;
holder[1] = basename;
holder[2] = numberlength;
}
//calculates the next image that will come
function nextNum() {
next = String(counter);
while(String(next).length<=holder[2].length-1) {
next="0"+next;
}
return next;
}
//handles the input of the keys
function keyHandler(key) {
if(key==39) {
//right key press
counter++;
//checks to see if the counter is out of bounds
if(counter<=holder[2]) {
topframe.location = base_path+holder[1]+"_"+nextNum()+".html";
} else {counter=holder[2]}
} else if(key==37) {
//left key press
counter--;
if(counter>0) {
topframe.location = base_path+holder[1]+"_"+nextNum()+".html";
} else {counter = 1;}
}
}
if anybody knows what the problem is that would be great!
heres a link to a ‘working’ gallerie:
http://ambwhitestudios.com/preview/001_p/003_g_s/