js实现跨窗体屏幕锁定并弹出对话框

function sAlert() 

{

var msgw,msgh,bordercolor;
msgw=450;
msgh=120;
titleheight=25;
bordercolor = \"#104E8B\";
var sWidth,sHeight;
sWidth=screen.width;
sHeight=screen.height;
var bgObj=window.parent.document.createElement(\"div\");
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\";

window.parent.document.body.appendChild(bgObj);

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,sty l 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 =tip1;
window.parent.document.body.appendChild(msgObj);
window.parent.document.getElementById(\"msgDiv\").appendChild(title);

}



注意:

1. 子窗体操作父窗体是,一定要在window后加上parent

2.注意IE兼容性问题:a: 调用createElement函数创建元素时,如果是加到 父窗体上的元素,创建时也要加上    window.parent.*.....因为IE浏览器下 ,加到父窗体上的元素必须属于父窗体。

   b:调用其中的函数,setAttribute()设置元素的属性时,其实IE浏览器支持这个函数,只是 在用这个函数设置class属性时,IE不支持,应该改用.设这相应的属性。

   c: 设置透明度这个属性时,bgObj.style.opacity=\"0.6\";
bgObj.style.filter = \"alpha(opacity = 60)\";

这两行代码 是设置一个属性,第二种形式是为了兼容IE的透明度属性设置。

js实现跨窗体屏幕锁定并弹出对话框,布布扣,bubuko.com

js实现跨窗体屏幕锁定并弹出对话框

上一篇:windows下查看真实的IP与MAC工具


下一篇:windows 2012 R2 core安装0x800f0906 -mgmt-infra出现0x800f0906