Published in: JavaScript
This code is used to take care of third level drop-downs in IE for the sons of suckerfish dropdown. Inserts iframes in third levels due to select items having an infinite z-index in IE. The original fix addressed second-level elements.
Based on: http://www.loadedguntheory.com/devblog/director/list/b5349120-f9ca-1027-b38e-00508df3c0f7.html And: http://www.htmldog.com/articles/suckerfish/dropdowns/
<script type="text/javascript"> <!--//--><![CDATA[//><!-- function insertAfter(newElement,targetElement) { var parent = targetElement.parentNode; if(parent.lastChild == targetElement) { parent.appendChild(newElement); } else { parent.insertBefore(newElement, targetElement.nextSibling); } } sfHover = function() { var sfEls = document.getElementById("nav").getElementsByTagName("LI"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { this.className += " sfhover"; var submenu = (this.getElementsByTagName("UL")) if(submenu.length) { var iframe = $(document.createElement("iframe")) iframe.setAttribute("scrolling", "no") iframe.setAttribute("frameborder", "0") iframe.addClassName('menu_iframe'); $("nav").insertBefore( iframe ) var ulSub = $(submenu[0]); if ( $(this).up(0) != $("nav") ) { parentWidth = this.up(0).scrollWidth parentOffset = this.up(0).offsetLeft + this.up(1).offsetLeft + 999 offsetTop = this.up(0).offsetTop + this.offsetTop + 3 iframe.style.left = parentWidth + parentOffset iframe.style.top = offsetTop; } else { iframe.style.top = ulSub.offsetTop + this.offsetTop + 2; iframe.style.left = ulSub.offsetLeft + this.offsetLeft; } iframe.style.width = ulSub.scrollWidth; iframe.style.height = ulSub.clientHeight; iframe.style.display = "inline"; } //if submenu.length } //mouseover sfEls[i].onmouseout=function() { this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); document.getElementsByClassName("menu_iframe").each(function(node) { node.style.display = "none"; }); } //mouseout } //for } //sfHover if (window.attachEvent) window.attachEvent("onload", sfHover); //--><!]]> </script>
You need to login to post a comment.
