Return to Snippet

Revision: 36629
at November 24, 2010 07:22 by threehz


Initial Code
function isIE7() {
    return (navigator.appVersion.indexOf("MSIE 7.")==-1) ? false : true;
}

function zIndexWorkaround() {
    // If the browser is IE7,
    if(isIE7())
    {
        /*
        ** For each div with class menu (i.e.,
        ** the thing we want to be on top),
        */
        
        $("ul.menu").parents().each(function() {
            var p = $(this);
            var pos = p.css("position");

            // If it's positioned,
            if(pos == "relative" ||
               pos == "absolute" ||
               pos == "fixed")
            {
                /*
                ** Add the "on-top" class name when the
                ** mouse is hovering over it, and remove
                ** it when the mouse leaves.
                */
                p.hover(function() {
                        $(this).addClass("on-top");
                    },
                    function() {
                        $(this).removeClass("on-top");
                    });
            }
        });
    }
}

Initial URL

                                

Initial Description

                                

Initial Title
Fix IE7 z-index bug for dropdown menus

Initial Tags

                                

Initial Language
JavaScript