Js implements cross-form screen locking and a dialog box pops up

Source: Internet
Author: User

Function sAlert ()

{

Var msgw, msgh, bordercolor;

Msgw = 450;

Msgh = 120;

Titleheight = 25;

Bordercolor = \ "# effece8b \";

Var sWidth, sHeight;

SWidth = screen. width; // obtain the width and height of the screen. For other parameters, see the value of screen width in the document.

SHeight = screen. height;

Var bgobj?##parent.doc ument. createElement (\ "div \"); // create an element,

BgObj. setAttribute ('id', 'bgdiv ');

BgObj. style. position = "absolute ";

BgObj. style. top = "0 ";

BgObj. style. background = "# cccccc ";

BgObj. style. filter = "progid: DXImageTransform. Microsoft. Alpha (style = 3, opacity = 25, finishOpacity = 75 ";

BgObj. style. opacity = "0.6 ";

BgObj. style. filter = "alpha (opacity = 60 )";

BgObj. style. left = "0 ";

BgObj. style. width = sWidth + "px ";

BgObj. style. height = sHeight + "px ";

BgObj. style. zIndex = "10000";/* set the object bgObj, that is, the div attributes, id, and css attributes */

Required bytes parent.doc ument. body. appendChild (bgObj);/* Add the bgObg object to the parent form */

Var msgobj?##parent.doc ument. createElement ("div ");

MsgObj. setAttribute ("id", "msgDiv ");

MsgObj. setAttribute ("align", "center ");

MsgObj. style. 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 titlemediaworkflow extends parent.doc ument. 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, styl e = 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 ";

Title. style. cursor = "pointer ";

Title. innerHTML = 'hello ';

Response response parent.doc ument. body. appendChild (msgObj );

Response response parent.doc ument. getElementById (\ "msgDiv \"). appendChild (title );

}

Note:

1. The parent form of the sub-form operation is. You must add a parent after the window.

2. note IE compatibility: a: when calling the createElement function to create an element, if it is an element added to the parent form, the window must be added during creation. parent. *..... in ie, the elements added to the parent form must belong to the parent form.

B: Call the function. When setAttribute () is used to set the attribute of an element, IE actually supports this function, but IE does not support this function when setting the class attribute. You should use this function instead. set the corresponding property.

C: When the transparency attribute is set, bgObj. style. opacity = \ "0.6 \";

BgObj. style. filter = \ "alpha (opacity = 60 )\";

The two lines of code are used to set an attribute. The second form is to be compatible with IE's transparent property settings.

For more information about the meanings of these attributes, see W3School, a great website for Learning web languages: Click to open the link.

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.