JavaScript Implementation page Adaptive reset visible Area height

Source: Internet
Author: User

1, this function is only applicable to the need to automatically fill or narrow the page to the visible area, and only a single subject to change the height of the demand.

varResetcontrol =function(ptask) {var_task = Ptask | |[], _islock=false, Bindevent=function(){                varme = This; $ (window). Bind (' Resize.reset ',function(event) {Fire.call (me); if(_task.length = = 0) {$ (window). Unbind (' Resize.reset ', Arguments.callee);            }                }); }, Fire=function () {                    //Current page Visible height                var_iheight =math.min (Window.innerheight, document.documentElement.clientHeight),//Overall height of the page_wheight =Math.max (Document.documentElement.clientHeight, Document.documentElement.scrollHeight, Document.body.clientHeight, document.body.scrollHeight),//Overall actual height of the page_bheight =Document.body.offsetHeight, _resetheight= 0; if(_iheight >_bheight) {                    //Current page Visible height-Overall actual height of the page_resetheight = _iheight-_bheight; } Else {                    //Current Page Visibility Height-Overall page height_resetheight = _iheight-_wheight; }                 for(vari = 0,l = _task.length;i < l;i++){                    var_h = _task[i][0].offsetheight; _h= (_h + _resetheight) < 200? £ º (_h +_resetheight); _task[i].css ("Height", _h + "px"); }            }         This. Push =function(pitem) {_task.push (pitem); }         This. init =function() {setTimeout (function() {Fire ();            Bindevent (); }, 100); }    }

JavaScript Implementation page Adaptive reset visible Area height

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.