|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
cant find javascript error
My page has an error in some of the javascript that was generated by Adobe Image ready for my rollovers.
The error I'm getting is. Error: 'document[...]' is null or not an object here is the chunck of code that declares all the functions and stuff. Code:
<SCRIPT TYPE="text/javascript">
<!--
function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}
function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
}
}
}
var preloadFlag = false;
function preloadImages() {
if (document.images) {
logo_guestbook_over = newImage("images/logo-guestbook_over.gif");
pics_over = newImage("images/pics-over.gif");
bios_over = newImage("images/bios-over.gif");
songs_over = newImage("images/songs-over.gif");
press_home_over = newImage("images/press-home_over.gif");
press_over = newImage("images/press-over.gif");
guestbook_over = newImage("images/guestbook-over.gif");
home_over = newImage("images/home-over.gif");
home_press_over = newImage("images/home-press_over.gif");
home_guestbook_over = newImage("images/home-guestbook_over.gif");
topchecker_home_over = newImage("images/topchecker-home_over.gif");
<!--Add more preload images here -->
preloadFlag = true;
}
}
// -->
</SCRIPT>
I've never really written my own javascript, so I'm not really sure how to debug this. |
|
#2
|
|||
|
|||
|
RE: cant find javascript error
I think I found an error in the function changeImages().. I have corrected it... Check it out and see..
<SCRIPT TYPE="text/javascript"> <!-- function newImage(arg) { if (document.images) { rslt = new Image(); rslt.src = arg; return rslt; } } //////Modified Function function changeImages() { if (document.images && (preloadFlag == true)) { for (var i=0; i<changeImages.arguments.length; i+=2) { document.images[changeImages.arguments[i]].src = changeImages.arguments[i+1]; } } } //////End modified function var preloadFlag = false; function preloadImages() { if (document.images) { logo_guestbook_over = newImage("images/logo-guestbook_over.gif"); pics_over = newImage("images/pics-over.gif"); bios_over = newImage("images/bios-over.gif"); songs_over = newImage("images/songs-over.gif"); press_home_over = newImage("images/press-home_over.gif"); press_over = newImage("images/press-over.gif"); guestbook_over = newImage("images/guestbook-over.gif"); home_over = newImage("images/home-over.gif"); home_press_over = newImage("images/home-press_over.gif"); home_guestbook_over = newImage("images/home-guestbook_over.gif"); topchecker_home_over = newImage("images/topchecker-home_over.gif"); <!--Add more preload images here --> preloadFlag = true; } } // --> </SCRIPT> |
|
#3
|
|||
|
|||
|
RE: cant find javascript error
Thanks for the help, but that change didnt fix the script error. Heres a link to the page if you wanna see the error in action. www.captainsupreme.com
|
|
#4
|
|||
|
|||
|
RE: cant find javascript error
I went through it.. But couldn't find where the error actually is.. Why don't you try generating the rollovers again through ImageReady.. It might not be the function that has got the problem.. It might be when the function is called.. Check for the parameters..
Why don't you try using Dreamweaver?? |
|
#5
|
|||
|
|||
|
RE: cant find javascript error
It looks like it's something with the FOR Next loop and the arguments in the ChangeImage function. I don't think you need to loop through the arguments because you already know what the arguments represent and what their array location is. Change the changeImage function to look like this and see if it works.
function changeImages() { if (document.images && (preloadFlag == true)) { document[changeImages.arguments[0]].src = changeImages.arguments[1]; } } let me know if that works as I really could not test it with out the immages, but when I loaded the page and moved my mouse over the image placeholders, I did not get any errors. |
|
#6
|
|||
|
|||
|
RE: cant find javascript error
Ok, I found the real error, kind of obvious, but I didn't catch it right away. Here is the corrected changeImage function.
Code:
function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length-1; i++) {
document[changeImages.arguments[0]].src = changeImages.arguments[1];
}
}
}
looks like the syntax of the For loop was wrong and it was looking for an array value greater than the number of elements in the array. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > cant find javascript error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|