Hi, i am trying to position an iframe shim behind a <ul> when it appears using mouseover. Just wanted some help on how to do it, possibly using getElementsByTagName().
The following is my markup example.
I tried the below Javascript but firstChild.nextSibling doesn't have those properties.
I also tried
Didnt think it would work and it certainly doesn't.
The following is my markup example.
Code:
<div id="headerNav">
<ul>
<li id="header_nav1" class="nav1"><a href="#">N</a></li>
<li id="header_nav2" class="nav2"><a href="">A</a>
<ul class="subCategories">
<li class="nav2"><a href="#">S</a></li>
<li class="nav2"><a href="#">H</a></li>
<li class="nav2"><a href="#">B</a></li>
</ul>
</li>
<li id="header_nav3" class="nav3"><a href="#">G</a></li>
</ul>
</div>
<iframe
id="DivShim"
src="javascript:false;"
scrolling="no"
frameborder="0"
style="position:absolute; top:0px; left:0px; display:none;">
</iframe>
I tried the below Javascript but firstChild.nextSibling doesn't have those properties.
Code:
<script>
startList = function() {
var DivRef = document.getElementById('headerNav');
var IfrRef = document.getElementById('DivShim');
if (document.all && document.getElementById) {
navRoot = DivRef.firstChild;
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
IfrRef.style.display = "block";
IfrRef.style.width = node.firstChild.nextSibling.offsetWidth;
IfrRef.style.height = node.firstChild.nextSibling.offsetHeight;
IfrRef.style.top = node.firstChild.nextSibling.style.top;
IfrRef.style.left = node.firstChild.nextSibling.style.left;
IfrRef.style.zIndex = node.firstChild.nextSibling.style.zIndex - 1;
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
IfrRef.style.display = "none";
}
}
}
}
}
window.onload=startList;
</script>
I also tried
Code:
nodeSubList = node.getElementsByTagName('ul');
IfrRef.style.top = nodeSubList[0].style.top;
etc...
Didnt think it would work and it certainly doesn't.