idlelife
01-29-2005, 05:44 PM
I am having some problems with javascript working across platforms. I have had the following results with the following code:
Code worked as expected on: Mac OSX with Safari, Mac OSX with FireFox, MacOSX with IE 5.2, Windows 2K with FireFox
Code did not work as expected on: Windows 2K with IE 5.0, Windows 2K with IE 6.0
The problem code (versions of this code exist in three places on the page) is as follows:
function left() {
if (imageNum > 0) {
imageNum--;
image = new Image();
image.src = tFileArray[imageNum];
--> image.onload = changeImg("img1",image.src);
image.src = tFileArray[imageNum+1];
image.onload = changeImg("img2",image.src);
image.src = tFileArray[imageNum+2];
image.onload = changeImg("img3",image.src);
image.src = tFileArray[imageNum+3];
image.onload = changeImg("img4",image.src);
}
}
The function “Left” is called when a user clicks on an unrelated image (a left arrow) and should scroll 4 images (these images are named “img1,img2,img3,img4” in the page. “tFileArray[]” is a collection of thumbnail file names (generally something like “tBlue4.jpg”). "imageNum" is a global variable that tracks image scrolling. The changeImg function is as follows:
function changeImg(id, image) {
eval("document."+id+".src=\""+image+"\"");
}
Originally, in the Left function, I had the eval statement instead of the function call, but this did not work either (although it did work on the Mac and with Firefox on Windows 2K).
In IE, I get a “Not Implemented” error at the line with the arrow on it. The first image (img1) is changed, but none of the later images are changed.
The page can be viewed at http://www.idlelife.net/portfolio/index.php. Please, let me know if I have left out any crucial information. Any suggestions would be appreciated.
Code worked as expected on: Mac OSX with Safari, Mac OSX with FireFox, MacOSX with IE 5.2, Windows 2K with FireFox
Code did not work as expected on: Windows 2K with IE 5.0, Windows 2K with IE 6.0
The problem code (versions of this code exist in three places on the page) is as follows:
function left() {
if (imageNum > 0) {
imageNum--;
image = new Image();
image.src = tFileArray[imageNum];
--> image.onload = changeImg("img1",image.src);
image.src = tFileArray[imageNum+1];
image.onload = changeImg("img2",image.src);
image.src = tFileArray[imageNum+2];
image.onload = changeImg("img3",image.src);
image.src = tFileArray[imageNum+3];
image.onload = changeImg("img4",image.src);
}
}
The function “Left” is called when a user clicks on an unrelated image (a left arrow) and should scroll 4 images (these images are named “img1,img2,img3,img4” in the page. “tFileArray[]” is a collection of thumbnail file names (generally something like “tBlue4.jpg”). "imageNum" is a global variable that tracks image scrolling. The changeImg function is as follows:
function changeImg(id, image) {
eval("document."+id+".src=\""+image+"\"");
}
Originally, in the Left function, I had the eval statement instead of the function call, but this did not work either (although it did work on the Mac and with Firefox on Windows 2K).
In IE, I get a “Not Implemented” error at the line with the arrow on it. The first image (img1) is changed, but none of the later images are changed.
The page can be viewed at http://www.idlelife.net/portfolio/index.php. Please, let me know if I have left out any crucial information. Any suggestions would be appreciated.