The Html body scroll bar is disabled and enabled

Source: Internet
Author: User

In the Write a page, the authenticated user does not log in or the session fails when the popup login box prevents page scrolling
Today, a function, the upper and lower left and right center, imitating the style of QQ space, the horizontal and vertical scroll bar to prohibit the code as follows:
<script type= "Text/javascript" >
Prohibit scroll bar
$ (document.body). CSS ({
"Overflow-x": "Hidden",
"Overflow-y": "Hidden"
});

Enable scroll bars
$ (document.body). CSS ({
"Overflow-x": "Auto",
"Overflow-y": "Auto"
});

</script>
I believe that you should have no objection to this code, if you have to give guidance to the master. The test results are as follows:
IE6: Disable scroll bar normal, start scroll bar error, double scroll bar appears and scroll bar scrolling page is unresponsive.
IE7: Disable scroll bar normal, start scroll bar error, double scroll bar appears and scroll bar scrolling page is unresponsive.
IE8: Disable scroll bar normal, start scroll bar normal.
IE9: Disable scroll bar normal, start scroll bar normal.
Chrome: Disable scroll bar normal, start scroll bar normal.
FireFox: Disable scroll bar normal, start scroll bar normal.

Rely on, again IE6 and IE7, Microsoft really should reflect on, so say do product must start to be responsible. Don't get far, the solution is to cancel this style without setting the overflow after overflow set hidden, the code is as follows:
To easily define a style class
<style type= "Text/css" >
. html-body-overflow
{
Overflow-x:hidden;
Overflow-y:hidden;
}
</style>

<script type= "Text/javascript" >
Prohibit scroll bar (default is not attached to this style class)
$ (document.body). Toggleclass ("Html-body-overflow");
Start scroll bar
$ (document.body). Toggleclass ("Html-body-overflow");
</script>
Of course, you can also directly clear the content of style, but the above approach is more intuitive, more simple.

The Html body scroll bar is disabled and enabled

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.