JS to achieve cross-form screen lock and pop-up dialog box

Source: Internet
Author: User

function Salert ()

{

var Msgw,msgh,bordercolor;

msgw=450;

msgh=120;

titleheight=25;

bordercolor = "#104E8B";

var swidth,sheight;

Swidth=screen.width; Take the width and height of the screen. Other parameters see the article screen wide height of the value

Sheight=screen.height;

var bgobj=window.parent.document.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 Object bgobj that is, div properties, id,css properties and so on * *

Window.parent.document.body.appendChild (Bgobj); /* Add the Bgobg object to the parent form * *

var msgobj=window.parent.document.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 = -75+document.documentelement.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=window.parent.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,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 ';

Window.parent.document.body.appendChild (Msgobj);

Window.parent.document.getElementById ("Msgdiv"). AppendChild (title);

}

Attention:

1. Subform Operation parent form is, be sure to add parent after window

2. Note IE compatibility problem: A: Call the CreateElement function to create an element, if it is added to the parent form elements, when created also add window.parent.* ... Because the elements that are added to the parent form must belong to the parent form under IE Explorer.

B: Call the function, setattribute () to set the attributes of the element, in fact, IE browser support this function, only in the use of this function to set the class property, IE does not support, should be used instead. Set this corresponding property.

C: When setting transparency this property, bgobj.style.opacity= "0.6";

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

The two lines of code are set to a property, and the second form is to be compatible with IE's Transparency property settings.

What is the meaning of these attributes, you can refer to a better learning web-related language of a website w3school: Click to open the link

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.