Advertisement
nickyb713

Untitled

Apr 22nd, 2011
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   <script language="javascript">
  2.     matchHeight=function(){
  3.          var divs,contDivs,maxHeight,divHeight,d;
  4.          // get all <div> elements in the document
  5.          divs=document.getElementsByTagName('div');
  6.          contDivs=[];
  7.          // initialize maximum height value
  8.          maxHeight=0;
  9.          // iterate over all <div> elements in the document
  10.          for(var i=0;i<divs.length;i++){
  11.               // make collection with <div> elements with class attribute 'container'
  12.               if(/\bcontainer\b/.test(divs[i].className)){
  13.                     d=divs[i];
  14.                     contDivs[contDivs.length]=d;
  15.                     // determine height for <div> element
  16.                     if(d.offsetHeight){
  17.                          divHeight=d.offsetHeight;
  18.                     }
  19.                     else if(d.style.pixelHeight){
  20.                          divHeight=d.style.pixelHeight;
  21.                     }
  22.                     // calculate maximum height
  23.                     maxHeight=Math.max(maxHeight,divHeight);
  24.               }
  25.          }
  26.          // assign maximum height value to all of container <div> elements
  27.          for(var i=0;i<contDivs.length;i++){
  28.               contDivs[i].style.height=maxHeight;
  29.          }
  30.     }
  31.     // execute function when page loads
  32.     window.onload=function(){
  33.          if(document.getElementsByTagName){
  34.               matchHeight();
  35.          }
  36.     }
  37.     </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement