日期:2014-05-16  浏览次数:20576 次

用JS弹出网页对话框后,如何让后面那一层变灰。 - Web 开发 / Ajax
如题,我想用JS弹出网页对话框后,后面那一怪变灰,变成不可操做。

------解决方案--------------------
<html>
<head>
<title> </title>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<style type= "text/css ">
*{margin:0;padding:0;}
</style>
</head>

<body>
<p> 测试 </p> <p> 测试 </p> <p> 测试 </p> <p> 测试 </p> <p> 测试 </p> <p> 测试 </p> <p> 测试 </p>
<p> 测试 </p> <p> 测试 </p> <p> 测试 </p> <p> 测试 </p> <p> 测试 </p> <p> 测试 </p> <p> 测试 </p> <p> 测试 </p>
<input type= "button " value= "点击这里 " onclick= "sAlert( '测试效果 <br/> 嗯!效果还不错! '); " />

<script type= "text/javascript " language= "javascript ">
function sAlert(str){
var msgw,msgh,bordercolor;
msgw=400;//提示窗口的宽度
msgh=100;//提示窗口的高度
titleheight=25 //提示窗口标题高度
bordercolor= "#336699 ";//提示窗口的边框颜色
titlecolor= "#99CCFF ";//提示窗口的标题颜色

var sWidth,sHeight;
sWidth=document.body.offsetWidth;//浏览器工作区域内页面宽度
sHeight=screen.height;//屏幕高度(垂直分辨率)


//背景层(大小与窗口有效区域相同,即当弹出对话框时,背景显示为放射状透明灰色)
var bgObj=document.createElement( "div ");//创建一个div对象(背景层)
//定义div属性,即相当于
// <div id= "bgDiv " style= "position:absolute; top:0; background-color:#777; filter:progid:DXImagesTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75); opacity:0.6; left:0; width:918px; height:768px; z-index:10000; "> </div>
bgObj.setAttribute( 'id ', 'bgDiv ');
bgObj.style.position= "absolute ";
bgObj.style.top= "0 ";
bgObj.style.background= "#777 ";
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);//在body内添加该div对象


var msgObj=document.createElement( "div ")//创建一个div对象(提示框层)
//定义div属性,即相当于
// <div id= "msgDiv " align= "center " style= "background-color:white; border:1px solid #336699; position:absolute; left:50%; top:50%; font:12px/1.6em Verdana,Geneva,Arial,Helvetica,sans-serif; margin-left:-225px; margin-top:npx; width:400px; height:100px; text-align:center; line-height:25px; z-index:100001; "> </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 = -75+document.documentElement.scrollTop+ "px ";
msgObj.style.width = msgw + "px ";
msgObj.style.height =msgh + "px ";
msgObj.style.textAlign = "center ";
msgObj.style.lineHeight = "25px &