Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document is not an object error

Status
Not open for further replies.

ronaloka

Technical User
Dec 16, 2000
2
0
0
ZA
Thanks in advance for help in correcting the following javascript error:
Line 39
Error: 'document[...]' is not an object

It's much appreciated!! Rona
-----------------------------------------------------------------------
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
function newImage(arg) {

if (document.images) {

rslt = new Image();

rslt.src = arg;

return rslt;

}

}

function changeImages() {

if (document.images &amp;&amp; (preloadFlag == true)) {

for (var i=0; i<changeImages.arguments.length; i+=2) {

(error line 39 here:) document[changeImages.arguments].src = changeImages.arguments[i+1];

}

}

}

var preloadFlag = false;

function preloadImages() {

if (document.images) {

overview_over = newImage(&quot;images/overview2.jpg&quot;);

location_over = newImage(&quot;images/location2.jpg&quot;);

rooms_over = newImage(&quot;images/rooms2.jpg&quot;);

prices_over = newImage(&quot;images/prices2.jpg&quot;);

directions_over = newImage(&quot;images/directions2.jpg&quot;);


preloadFlag = true;

}

}


// -->

</SCRIPT>

</HEAD>

(and in the body, the following)

<TD>
<A href=&quot;overview.html&quot;
onmouseout=&quot;changeImages('overview', 'images/overview2.jpg'); return true;&quot;
onmouseover=&quot;changeImages('overview', 'images/overview1.jpg'); return true;&quot; >
<IMG border=0 height=300 name=overview src=&quot;images/overview1.jpg&quot; width=80></A>
</TD>

<TD><IMG height=300 src=&quot;images/spacer.gif&quot; width=8></TD>

<TD>
<A href=&quot;location.html&quot;
onmouseout=&quot;changeImages('location', 'images/location2.jpg'); return true;&quot; onmouseover=&quot;changeImages('location', 'images/location1.jpg'); return true;&quot; >
<IMG border=0 height=300 name=location src=&quot;images/location1.jpg&quot; width=49></A>
</TD>

<TD><IMG height=300 src=&quot;images/spacer.gif&quot; width=8></TD>

<TD>
<A href=&quot;rooms.html&quot;
onmouseout =&quot;changeImages('rooms', 'images/rooms2.jpg'); return true;&quot; onmouseover=&quot;changeImages('rooms', 'images/rooms1.jpg'); return true;&quot; >
<IMG border=0 height=300 name=rooms src=&quot;images/rooms1.jpg&quot; width=70></A>
</TD>

<TD><IMG height=300 src=&quot;images/spacer.gif&quot; width=8></TD>

<TD>
<A href=&quot;prices.html&quot;
onmouseout=&quot;changeImages('prices', 'images/prices2.jpg'); return true;&quot; onmouseover=&quot;changeImages('prices', 'images/prices1.jpg'); return true;&quot; >
<IMG border=0 height=300 name=pricess src=&quot;images/prices1.jpg&quot; width=75></A>
</TD>

<TD><IMG height=300 src=&quot;images/spacer.gif&quot; width=8></TD>

<TD>
<A href=&quot;directions.html&quot;
onmouseout=&quot;changeImages('directions', 'images/directions2.jpg'); return true;&quot; onmouseover=&quot;changeImages('directions', 'images/directions1.jpg'); return true;&quot; >
<IMG border=0 height=300 name=publish src=&quot;images/directions1.jpg&quot; width=83></A>
</TD>
 
how about document.changeImages.arguments.src?

I have no idea if that is a correct way to reference a function, but it looks more consistent with the DOM.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
hi,
here is the answer for u'r error....
replace the line 39 by the following code it will start working !!
---------------------------------
var objImg ;
objImg = eval(&quot;document.&quot;+ changeImages.arguments);
objImg.src = changeImages.arguments[i+1];
------------------------------------
i hope u got the point where the problem was, if not ...

in the line document[changeImages.arguments]. ....
&quot;changeImages.arguments&quot; is a string ,you can not give string as the argument.
But if u still want to refer as array use
window.document.images[0] , so u'r argument for change image should be should be a number not the string.
have a good day
- ayyappan
 
Hooray! I figured it out. Thanks Tom and ayyappan for your suggestions, but it came down to two simple typos I had overlooked:

In the body script:

<IMG border=0 height=300 name=pricess src=&quot;images/prices1.jpg&quot; width=75>

I changed name=pricess to name=prices

<IMG border=0 height=300 name=publish src=&quot;images/directions1.jpg&quot; width=83>

I changed name=publish to name=directions

and that fixed everything, and now it all works perfectly!!!

Rona
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top