Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Please HELP: Why doesnt this js work in Netcape?


Message #1 by "Joe Coppola" <joco@e...> on Fri, 15 Feb 2002 16:30:20 -0500
Philip,

Thanks so much for the help.. I knew it had to be something silly!  I
was going crazy as to why it didn't work!

Thanks again,
Joe Coppola

> -----Original Message-----
> From: Philip Cole [mailto:dhtml_phil@p...] 
> Sent: Saturday, February 16, 2002 12:41 PM
> To: javascript
> Subject: [javascript] Re: Please HELP: Why doesnt this js 
> work in Netcape?
> 
> 
> Hi Joe
> 
> All of your code is correct except that you are using the 
> wrong type of 
> brackets for document.images.  All the collections such as 
> document.images, and document.all in Internet Explorer, are basically 
> stored as arrays of elements.  As you probably know, you access array 
> elements like so:
>   myArray = new Array();
>   myArray[0] = "first";
>   myArray[1] = "second";
> 
> Note the square brackets.  The same is true for the built-in 
> collections, 
> so your over() and out() functions should be:
> 
>   function over(imgName)  {
>     if (document.images)  {
>       var test = imgName.substring(0,7);
>       document.images[test].src = eval(imgName + "o.src");
>     }
>   }
> 
>   function out(imgName) {
>     var test1 = imgName.substring(0,7);
>     if (document.images) 
>       document.images[test1].src = eval(imgName + "n.src");
>   }
> 
> Now the rollovers should work fine.
> 
> P.S. Notice that I put curly brackets round both statements 
> in the over() 
> method. At the moment, only "var test = imgName.substring(0,7);" is 
> checked in the if(documen.images) statement.
> 
> Regards
> 
> Philip
> -------------------------
> dhtml_phil@p...
> $subst('Email.Unsub').
> 


  Return to Index