News wrote:
<oz*********@gm ail.com> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.com.. .
Try this:
var divs = document.getEle mentsByTagName( "div");
for (var i =0; i < divs.length; i++)
divs[i].style.zIndex = i;
if you need to get all the divs "under" a certain parent (container)
you could do this instead:
var divs = container.getEl ementsByTagName ("div");
I got it working on IE but not on Modzilla here is the URL
http://www.wyght.com/warren/layers.html
Why does this work on IE but not Modzilla nor on NN?
Because you have:
function myDiv()
{
var top=0;
var divs = you.getElements ByTagName("div" );
--------------^^^
Where 'you' is the id of the div. IE adds ids and names as global
variables that refer to the related DOM object, other browsers may mimic IE
in some circumstances[1], but not here. For them, 'you' is undefined, an
error is thrown and that's as far as the script goes.
It seems that what you want to do is make the n + 1 div visible each time.
So loop through until you find the visible one, make it hidden, then set
the next (or zero-th if at last div) to visible.
The rest of your script has so many errors that it surprising that it works
at all. Try:
<script type="text/javascript">
function myDiv()
{
// Declare variables
var you = document.getEle mentById('you') ;
var divs = you.getElements ByTagName("div" );
var numDivs = divs.length;
var x=0;
// Look for first non-hidden div
while (divs[x].style.visibili ty == 'hidden'){
++x;
}
// Set it to hidden
divs[x].style.visibili ty = 'hidden';
// Set the next or zero-th to visible
divs[++x % numDivs].style.visibili ty = 'visible';
// Set the timeout
setTimeout("myD iv();",100);
}
You need to add feature detection and replace the form element with a div.
1. This IE-ism was so pervasive that other browsers felt impelled to
implement IE's proprietary behaviour because of the number of issues it
caused. However, it is only supported in Gecko browsers where the DOCTYPE
is not strict or XHTML.
--
Rob