[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 535
  • Last Modified:

Resize <div> cross browser

I am using this code to resize a <div> dynamically and works fine in IE 6 but it does not work in NS 7.1 or Opera or Firefox and it needs to at least work in Mozilla-based browsers and IE5.x.  I know the problem is in line 6.

<script type="text/javascript">        
  function adjustDiv()
      {
      var rb = document.getElementById('rightBorder').offsetHeight;
      var lsb = document.getElementById('leftSidebar').offsetHeight-rb;
      document.getElementById('rightBorder').style.height = document.getElementById('mainContent').height-lsb || document.getElementById('mainContent').offsetHeight-lsb;
}
      window.onload=adjustDiv
</script>
0
andrewshka
Asked:
andrewshka
1 Solution
 
COBOLdinosaurCommented:
Standard compliant browser require the unit of measure for style settings:

<script type="text/javascript">        
  function adjustDiv()
     {
     var rb = document.getElementById('rightBorder').offsetHeight;
     var lsb = document.getElementById('leftSidebar').offsetHeight-rb;
     var=hgt = document.getElementById('mainContent').height-lsb || document.getElementById('mainContent').offsetHeight-lsb;
 document.getElementById('rightBorder').style.height=hgt+'px';
}
     window.onload=adjustDiv
</script>

Cd&
0
 
andrewshkaAuthor Commented:
SWEET!  That works great, thanks so much COBOLdinosaur :)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now