The javascript div mask layer blocks the entire page.

Source: Internet
Author: User

The specific solution is as follows:
1. The clientHeight, offsetHeight, and scrollHeight attributes of the document. body object under IE and FF.
ClientHeight
In IE and FF, this attribute is no different. It refers to the visible area of the browser, that is, the height of the page display space remaining in the toolbar status bar of the browser.
OffsetHeight
In IE, offsetHeight is also the height (including edges) of the visible area of the browser)
In FF, offsetHeight indicates the height of the page content.
ScrollHeight
In IE, scrollHeight is the height of the page content, which can be smaller than clientHeight
In FF, scrollHeight indicates the webpage content height, but the minimum value is clientHeight.
2. The following is a solution to cross-browser acquisition of the current page height.
Copy codeThe Code is as follows:
Function getPageSize ()
{
Var body = document.doc umentElement;
Var bodyOffsetWidth = 0;
Var bodyOffsetHeight = 0;
Var bodyScrollWidth = 0;
Var bodyScrollHeight = 0;
Var pageDimensions = [0, 0];
PageDimensions [0] = body. clientHeight;
PageDimensions [1] = body. clientWidth;
BodyOffsetWidth = body. offsetWidth;
BodyOffsetHeight = body. offsetHeight;
BodyScrollWidth = body. scrollWidth;
BodyScrollHeight = body. scrollHeight;
If (bodyOffsetHeight> pageDimensions [0])
{
PageDimensions [0] = bodyOffsetHeight;
}
If (bodyOffsetWidth> pageDimensions [1])
{
PageDimensions [1] = bodyOffsetWidth;
}
If (bodyScrollHeight> pageDimensions [0])
{
PageDimensions [0] = bodyScrollHeight;
}
If (bodyScrollWidth> pageDimensions [1])
{
PageDimensions [1] = bodyScrollWidth;
}
Return pageDimensions;
}

3. A div must be placed on the page as the mask layer. below is the css style of the mask layer.
Copy codeThe Code is as follows:
. LockDiv
{
Position: absolute;
Left: 0;
Top: 0;
Height: 0;
Width: 0;
Border: 2 solid red;
Display: none;
Text-align: center;
Background-color: # DBDBDB;
Filter: Alpha (opacity = 60 );
}

4. Use the following javascript on the client to close the entire page with the mask layer.
Copy codeThe Code is as follows:
Var sandglassSpan = 1;
Var timeHdl;
Function DisablePage ()
{
Var ctrlSandglass = document. getElementById ("divSandglass ");
If (sandglassSpan = 0)
{
Window. clearTimeout (timeHdl );
CtrlSandglass. style. display = "none ";
Document. body. style. cursor = 'auto ';
SandglassSpan = 1;
}
Else
{
Document. body. style. cursor = 'wait ';
Var pageDimensions = getPageSize ();
CtrlSandglass. style. top = 0;
CtrlSandglass. style. left = 0;
CtrlSandglass. style. height = pageDimensions [0];
CtrlSandglass. style. width = pageDimensions [1];
CtrlSandglass. style. display = "block ";
TimeHdl = window. setTimeout (DisablePage, 200 );
}
}

5. If the ASP.net Validator control is used on the page, use the following javascript.
Copy codeThe Code is as follows:
Var sandglassSpan = 1;
Var timeHdl;
Function DisablePageHaveValidator ()
{
Var ctrlSandglass = document. getElementById ("divSandglass ");
If (false = Page_IsValid)
{
SandglassSpan = 0;
}
If (sandglassSpan = 0)
{
Window. clearTimeout (timeHdl );
CtrlSandglass. style. display = "none ";
Document. body. style. cursor = 'auto ';
SandglassSpan = 1;
}
Else
{
Document. body. style. cursor = 'wait ';
CtrlSandglass. style. display = "block ";
Var pageDimensions = getPageSize ();
CtrlSandglass. style. top = 0;
CtrlSandglass. style. left = 0;
CtrlSandglass. style. height = pageDimensions [0];
CtrlSandglass. style. width = pageDimensions [1];
TimeHdl = window. setTimeout (DisablePageHaveValidator, 200 );
}
}

6. The DisablePage and DisablePageHaveValidator methods can be called at the onclick event of the button or at other times.

Related Article

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.