JS effect-Implementation of my dialog box

Source: Internet
Author: User
A dialog box is a commonly used tool for displaying information on webpages. Therefore, I have implemented a small dialog box myself. Dialog = {
Createdialog: function (content, newid ){
Mask ();
VaR dialogbox = Document. createelement ('div ');
Dialogbox. innerhtml = content;
If (! Ctit. Utility. isnull (newid )){
Dialogbox. ID = newid;
} Else {
Dialogbox. ID = "_ dialogbox __";
}
VaR width = 300;
VaR Height = 500;
VaR left = parseint (ctit. Utility. getviewwidth ()-width)/2 + document.doc umentelement. scrollleft );
VaR Top = parseint(document.doc umentelement. clientheight-height)/2 + document.doc umentelement. scrolltop );
Element. setstyle (dialogbox, {position: "absolute", zindex: 1010, left: Left + "PX", top: Top + "PX", width: parseint (width) + "PX", height: parseint (height) + "PX "});
Dialogbox. style. backgroundcolor = "# fff ";
Document. Body. appendchild (dialogbox );
Dialog. Keepon (dialogbox. ID );
Return dialogbox;
},
Resetwidthheight: function (ID, width, height ){
VaR o = $ (ID );
O. setstyle ({width: parseint (width) + "PX", height: parseint (height) + "PX "});
},
Fixedwh: function (ID ){
VaR o = $ (ID );
VaR width = 333;
VaR Height = 555;
O. setstyle ({width: parseint (width) + "PX", height: parseint (height) + "PX "});
},
Keepon: function (ID ){
VaR o = $ (ID );
VaR width = element. getwidth (O );
VaR Height = element. getheight (O );
VaR left = parseint (ctit. Utility. getviewwidth ()-width)/2 + document.doc umentelement. scrollleft );
VaR Top = parseint(document.doc umentelement. clientheight-height)/2 + document.doc umentelement. scrolltop );
O. setstyle ({left: Left + "PX", top: Top + "PX "});
Cleartimeout (dialog. Timing );
Dialog. Timing = setTimeout ("dialog. Keepon ('" + O. ID + "');", 300 );
},
Removedialog: function (ID ){
VaR o = $ (ID );
Cleartimeout (dialog. Timing );
Document. Body. removechild (O );
Unmask ();
}
}

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.