Reduction of adaptive height of script control

Source: Internet
Author: User

Function vvheight (){
Var sideleft = document. getElementById ("content-left"). scrollHeight;
Var sideright = document. getElementById ("content-right"). scrollHeight;
LayoutHeight = Math. max (sideleft, sideright );
Document. getElementById ("content-left"). style. height = layoutHeight + "px ";
Document. getElementById ("content-right"). style. height = layoutHeight + "px ";
}

I want to use a script to control the adaptive height. I used the code above to control the adaptive height of the left and right columns.
However, some pages are long because of many content, and some pages have less content, so the code used cannot be shortened!
I just want to reduce the content when there are few accesses. How should I write the code? Thank you!Copy codeThe Code is as follows: function vvheight (){
Var CL = document. getElementById ("content-left ");
Var CR = document. getElementById ("content-right ");
While (parseInt (CL. scrollHeight) = parseInt (CL. style. height) {CL. style. height = parseInt (CL. style. height)-30 + "px "}
Var sideleft = CL. scrollHeight;
While (parseInt (CR. scrollHeight) = parseInt (CR. style. height) {CR. style. height = parseInt (CR. style. height)-30 + "px "}
Var sideright = CR. scrollHeight;
LayoutHeight = Math. max (sideleft, sideright );
CL. style. height = layoutHeight + "px ";
CR. style. height = layoutHeight + "px ";
}

Answer:
In IE and Opera, the default value of style. overflowY of DIV is "auto", and the above Code will not be faulty.

In Firefox and Safari, the default value of style. overflowY of DIV is "" (equivalent to "hidden"). Therefore, if you use the above Code directly, an error will occur. Manually adjust style. overflowY = "auto ".Xmlns = "http://www.w3.org/1999/xhtml">


Content left

Content left

Content left

Content left

Content left

Content left

Content left

Content left

Content left

Content left

Content left

  • 55 × 65
  • 60 × 80
  • 90 × 90
  • 110 × 73
  • 118x53
  • 146x53
  • 170 × 65
  • Others
    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 1

    Content 2

    Content 2

    Content 2

    Content 2

    Content 2

    Content 2

    Content 2

    Content 2

    Content 3

    Content 3

    Content 3

    Content 3

    Content 3

    Content 3

    Content 3

    Content 3

    Content 3

    Content 3

    Content 3

    Content 3

    Content 3

    Content 3

    Content 3

    Content 3

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 4

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 5

    Content 6

    Content 6

    Content 6

    Content 6

    Content 6

    Content 6

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 7

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

    Content 8

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.