Link to home
Create AccountLog in
Avatar of canibefrank
canibefrank

asked on

display:none; element height issue, ifarme shim - multiple colapsable divs

Hi All,

I have a the need for a menu (lets call it 'FON - float over nav') to position itself over the main workspace. I have a number of divs that open and close onclick using display:none; function that works great.

The problem comes with IE6 where by the FON has select feilds shining through, no problem I thought and added an iframe shim.

However, dependent on the page load state of the FON, if open I get a height say 300px, if closed I get 0px. When I open the FON from a closed start state the iframe doesn't catch up, i.e. it doesn't pick up the hieght of the now open FON's containing div.

To compound the matter I have colapsible sub elements within the containing FON div.

Is there any way to catch the height on changing the div's state from display:none; to display:'';

Heres an example of the code.


<html>
<head>
<script type="text/javascript">
    <!--
        function hideshow(element) {
                if (element.style.display=="none") 
                {
                    element.style.display="";
                } 
                else 
                {
                    element.style.display="none";
                }
        }
	-->
</script>
</head>
<body>
<div id="toolsleft" onclick="hideshow(document.getElementById('toolsleftopencont'));" title="expand">OPEN/CLOSE THE NAV</div>  
 
<div id="toolsleftopencont" style="display:none;">
 
    <h2 onclick="hideshow(document.getElementById('navgroup1'));hideshow(document.getElementById('navgroup1closed'));">Nav Item Group header</h2>
 
    <div id="navgroup1">
 
        <ul>
            <li>Nav Item</li>
            <li>Nav Item</li>
            <li>Nav Item</li>
            <li onclick="hideshow(document.getElementById('subcont1'));">Expandable Item</li>
            <li id="subcont1" class="subcont" style="display:none;">         
                <ul>
                    <li>Sub Nave Item</li>
                    <li>Sub Nave Item</li>
                    <li>Sub Nave Item</li>
                </ul> 
            </li>  
            <li>Nav Item</li>
            <li>Nav Item</li>
        </ul> 
        
    </div><!-- #navgroup1 -->
    
    <!-- Repeat navs as necessary -->
            
</div><!-- #toolsleftopencont -->
 
<!--[if lt IE 7]>	
<script type="text/javascript">
	var ltoolsH = document.getElementById('toolsleftopencont').offsetHeight;
	alert(ltoolsH);       
	//transparent iframe shim to block select fields from shining through
	document.write("<iframe id='toolsleftiframe' src='BLOCKED SCRIPTfalse;' style='height:"+ltoolsH+"px;position:absolute;z-index:-1;width:100%;filter:mask();'></iframe>");
</script>    
<![endif]-->
</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Pravin Asar
Pravin Asar
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of canibefrank
canibefrank

ASKER

Hi pravinasar,

That fits the bill perfectly, your a star thanks a lot.
Nice one works a treat, exactly whta was required. Thanks.
Glad to be of some help.

Thanks for the Grade.

-PA