Results 1 to 3 of 3

Thread: [RESOLVED] ie7 window.onresize

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    354

    Resolved [RESOLVED] ie7 window.onresize

    I had to write a work around for the code i found here:

    http://www.webmasterworld.com/forum91/3429.htm

    Code:
    function resize(){ 
    
        var frame = document.getElementById("frame1"); 
        var htmlheight = document.body.parentNode.scrollHeight; 
        var windowheight = window.innerHeight;
        
        if ( htmlheight < windowheight ) 
        { 
            document.body.style.height = windowheight + "px";
            frame.style.height = windowheight + "px"; 
        } 
        else { 
            document.body.style.height = htmlheight + "px"; 
            frame.style.height = htmlheight + "px"; 
        } 
    }
    The code works in firefox and I just thought some minor tweaks and it would work in ie7. Well, apparently in ie7 the resize event gets called when each of the line in the if statement get executed. So, ie7 goes into a nice loop.

    I wrote a workaround below that seems to work. However, anybody know a more graceful besides using a timer?

    Code:
    <script type="text/javascript">
    
        //<![CDATA[
    
    
        function wait() {
        
            if (document.getElementById("wait").value == "f") {
                document.getElementById("wait").value = "t";
                resize();
                
            }
            else {
                self.setTimeout("change()",500);
            }
        
        }
        
        function change() {
            document.getElementById("wait").value = "f";
        }
    
    
     
        function resize(){ 
        
            //http://www.webmasterworld.com/forum91/3429.htm
            
               
            var frame = document.getElementById("gets"); /*frame is a div*/
            var htmlheight = document.body.parentNode.scrollHeight; /*window.innerHeight; for FF*/
            var windowheight = document.documentElement.clientHeight;
            
          
           //div#main, div#dpspane, div#main_tabs, div#case_tabs,div#footer 
            if ( htmlheight < windowheight ) 
            { 
            
                document.body.style.height = windowheight + "px";            
                document.getElementById("gets").style.height = windowheight + "px";
                //document.getElementById("main").style.height = windowheight + "px";
    
                
            } //end if
            else { 
           
                document.body.style.height = windowheight + "px";             
                document.getElementById("gets").style.height = windowheight + "px";  
                //document.getElementById("main").style.height = windowheight + "px";          
                
                
            }
            
        
            
            
                             
        }
        
       
       window.onresize = wait;
    
       
        //]]>
    </script>

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: ie7 window.onresize

    Grab this.

    Use it like this:
    Code:
    function resize()
    {
        removeEHandler(window, 'resize', arguments.callee);
        
        var frame = document.getElementById("frame1"); 
        var htmlheight = document.body.parentNode.scrollHeight; 
        var windowheight = window.innerHeight;
        
        if ( htmlheight < windowheight ) 
        { 
            document.body.style.height = windowheight + "px";
            frame.style.height = windowheight + "px"; 
        } 
        else { 
            document.body.style.height = htmlheight + "px"; 
            frame.style.height = htmlheight + "px"; 
        } 
        
        addEHandler(window, 'resize', arguments.callee);
    }
    
    addEHandler(window, 'resize', resize);

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    354

    Re: ie7 window.onresize

    That worked beautifully in ie6/7.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width