Javascript pop-up layer

Source: Internet
Author: User

Tag: In the Javascript pop-up window, the layer mode dialog box is displayed.

Function salert (STR, time ){
VaR msgw, msgh, bordercolor;
Msgw = 400; // width
Msgh = 100; // height
Titleheight = 25 // Title height
Bordercolor = "#336699"; // boder color
Titlecolor = "#99 CCFF"; // Title color
VaR swidth, sheight;
Swidth = Document. Body. offsetwidth;
Sheight = screen. height;
VaR bgobj = Document. createelement ("Div ");
Bgobj. setattribute ('id', 'bgdiv ');
Bgobj. style. Position = "absolute ";
Bgobj. style. Top = "0 ";
Bgobj. style. Background = "#000 ";
Bgobj. style. Filter = "progid: DXImageTransform. Microsoft. Alpha (style = 3, opacity = 25, finishopacity = 75 ";
Bgobj. style. Opacity = "0.6 ";
Bgobj. style. Left = "0 ";
Bgobj. style. width = swidth + "PX ";
Bgobj. style. Height = sheight + "PX ";
Bgobj. style. zindex = "10000 ";
Document. Body. appendchild (bgobj );
VaR msgobj = Document. createelement ("Div ")
Msgobj. setattribute ("ID", "msgdiv ");
Msgobj. setattribute ("align", "center ");
Msgobj. style. Background = "white ";
Msgobj. style. Border = "1px solid" + bordercolor;
Msgobj. style. Position = "absolute ";
Msgobj. style. Left = "50% ";
Msgobj. style. Top = "50% ";
Msgobj. style. font = "12px/1.6em verdana, Geneva, Arial, Helvetica, sans-serif ";
Msgobj. style. marginleft = "-225px ";
Msgobj. style. margintop = -7520.document.doc umentelement. scrolltop + "PX ";
Msgobj. style. width = msgw + "PX ";
Msgobj. style. Height = msgh + "PX ";
Msgobj. style. textalign = "center ";
Msgobj. style. lineheight = "25px ";
Msgobj. style. zindex = "10001 ";
VaR Title = Document. createelement ("H4 ");
Title. setattribute ("ID", "msgtitle ");
Title. setattribute ("align", "center ");
Title. style. Margin = "0 ";
Title. style. Padding = "3px ";
Title. style. Background = bordercolor;
Title. style. filter = "progid: DXImageTransform. microsoft. alpha (startx = 20, starty = 20, finishx = 100, finishy = 100, style = 1, opacity = 75, finishopacity = 100 );";
Title. style. Opacity = "0.75 ";
Title. style. Border = "1px solid" + bordercolor;
Title. style. Height = "18px ";
Title. style. font = "12px verdana, Geneva, Arial, Helvetica, sans-serif ";
Title. style. color = "white ";

VaR waitmsg = "Please wait ...";

Title. innerhtml = waitmsg;
VaR sec = time;
VaR clearalertfun = function (){
Document. Body. removechild (bgobj );
Document. getelementbyid ("msgdiv"). removechild (title );
Document. Body. removechild (msgobj );
}
Timerid = Window. setinterval (function (){
Try {
If (SEC <0 ){
Title. onclick = clearalertfun;
Title. style. cursor = "Pointer ";
Window. clearinterval (timerid );
Document. getelementbyid ("msgtitle"). innerhtml = 'Operation timed out, please click Close'
} Else
Document. getelementbyid ("msgtitle"). innerhtml = waitmsg + sec -- +'s ';
} Catch (E)
{
Window. clearinterval (timerid );
}
;}, 1000 );

Document. Body. appendchild (msgobj );
Document. getelementbyid ("msgdiv"). appendchild (title );
VaR TXT = Document. createelement ("p ");
TXT. style. Margin = "1em 0"
TXT. setattribute ("ID", "msgtxt ");
TXT. innerhtml = STR;
Document. getelementbyid ("msgdiv"). appendchild (txt );
}
Function calert ()
{
Document. Body. removechild (document. getelementbyid ("bgdiv "));
Document. getelementbyid ("msgdiv"). removechild (document. getelementbyid ("msgtitle "));
Document. Body. removechild (document. getelementbyid ("msgdiv "));
}

Modified from: http://www.cnblogs.com/blodfox777/archive/2008/05/26/1207337.html

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.