[thelist] js function to turn off all images

Karen Whitman karen at dieseldesign.com
Wed Feb 21 13:36:57 CST 2001


ok, i am growing weary on my quest to create/collect a JavaScript that turns
off all images in an array - in a page that uses layers - that worked on all
browsers.  i would like to loop through the array and set all image src's to
their off values.   the problem has been in Netscape - getting Netscape to
find the #$*% layers and the images inside of them.

i have tried passing the layer name through as an argument, and below, i
have even hard coded one of the layers' names....but  noooooo, Netscape
returns a 'layer1 is not defined'  (i have tried renaming the div, calling
it a layer instead of a div, using ID=layer1, and name=layer1).  is this
possible to do?  i know you can turn images off in RandomLayerX from inside
of RandomLayerY...so i would think this should be possible.

also, and maybe this is my problem, i am getting a syntax error telling me
to put ";" after "else(document.layers)"  i think this is wrong, but both IE
and NN asked for it to be there...any thoughts?

i have tried the following (with help from some of you, thanks):


function switch_off_anyArray(i,layer) {

        for(var i=0; i<anyArray.length;i++)
        	{

			if (document.all) {
    			document.images[anyArray[i]].src = off[i].src;   // this part works
in IE or if there are no layers in NN.
  			}

e(document.layers);{ 
   			document[layer1].document.images[anyArray[i]].src = off[i].src;  //this is the part that is driving me mad 
  			}
        }
}


::::::::::::::::::::


function switch_off_anyArray(i,layer) {

        for(var i=0; i<anyArray.length;i++)
        	{
             
			 	if (document.all) {
    			document.images[anyArray[i]].src = off[i].src;
  				}
  				else(document.layers); { 
   				 document.layers[layer1].document.images[anyArray[i]].src = off[i].src;  //a second attempt to call the images in the layers
  				}
        }
}

:::::::::::::::::::::::


216.217.81.67/turnoffall.html  has the basic working code - not in layers.
216.217.81.67/turnoffall2.html has the non-working layer code that im playing with now. 

i apologize for the long message with code included. i guess i should include a tip then.

<tip>Dreamweaver's rollover and it seems the one used by jason http://www.bsu.edu/World2000/research/burk/
(i did not test it but it appears to) are the only images swap scripts i have seen that will communicate between layers on all browsers, allowing you to shut off/on images inside of layers from inside of other layers. I needed this for a multilevel navigation.  Which is how i would like to use the *#$ function im trying to write.</tip>
</tip>

Karen Whitman
Web Development
Diesel Design






More information about the thelist mailing list