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, 07: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: 3
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, 05: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: 4
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, 02: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: 3
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, 03: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: 4
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, 11:18 AM
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: 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.

Reply With Quote
  #6  
Old September 12th, 2003, 12: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: 5
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!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

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




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek