Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old September 10th, 2003, 08:05 PM
DorkRawk DorkRawk is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 173 DorkRawk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to DorkRawk
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.

Reply With Quote
  #2  
Old September 11th, 2003, 06:06 AM
nazly nazly is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Colombo,SriLanka
Posts: 1,325 nazly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 18 sec
Reputation Power: 3
Send a message via Yahoo to nazly
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>

Reply With Quote
  #3  
Old September 12th, 2003, 03:57 AM
DorkRawk DorkRawk is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 173 DorkRawk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to DorkRawk
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

Reply With Quote
  #4  
Old September 12th, 2003, 04:45 AM
nazly nazly is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Colombo,SriLanka
Posts: 1,325 nazly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 18 sec
Reputation Power: 3
Send a message via Yahoo to nazly
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??

Reply With Quote
  #5  
Old September 12th, 2003, 12:18 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
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.

Reply With Quote
  #6  
Old September 12th, 2003, 01:22 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
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.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > cant find javascript error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT