js中弹出一个新窗口后屏蔽其他窗口



<html>
<head>

<style type="text/css">
#mask {
position:absolute;
top:0;
left:0;
background-color:#000;
filter:alpha(opacity=20);
-moz-opacity:0.2;
-khtml-opacity: 0.2;
opacity: 0.2;
z-index : 1000;
width: 1000px;
height:400px;
display : none;
}

span.btn{
color:red;
background-color:#eee;
border: 1px solid green;
padding : 3px 5px;
border-radius: 5px;
}

#hide_mask{
width: 600px;
height: 120px;
margin:auto;
font-size : 22px;
font-weight: bold;
color: red;
border: 2px solid #FFa;
line-height : 120px;
padding: 0 50 0 50;
border-radius: 25px;
background-color: green;
}

#top_bar{
width: 100px;
height: 150px;

}

</style>

<script type="text/javascript">

window.onload = function(){

var fn_show_mask = function (){
var body_width = document.body.offsetWidth;
var body_height = document.body.offsetHeight;

var mask = document.getElementById("mask");
mask.style.width = body_width + "px";
mask.style.height = body_height + "px";
mask.style.display = "block";




}

//get sumbit button.
var submit_button = document.getElementById("submit_button");
// set onclick event method.
submit_button.onclick = fn_show_mask;


// get mask element.
var hide_mask = document.getElementById("hide_mask");
// set onclick event method.
hide_mask.onclick = function(e,i){
this.parentNode.style.display = "none";
}

//get span
var span_click ;

if(document.getElementsByClassName){
span_click = document.getElementsByClassName("btn")[0];
}else{
span_click = document.getElementById("span_click");
}

// set onclick event method.
span_click.onclick = fn_show_mask;




}




</script>

</head>
<body>

<div id="mask">
<div id="top_bar"></div>
<div id="hide_mask"> Click Me To Hide</div>
</div>


<div style="width:600px;margin:auto;padding-top:50px;">

<h4>点击 <span class="btn" id="span_click">Click Me</span>,出现遮罩层。</h4>
<form>
<table>
<tr>
<td>标题:</td>
<td>
<input type="text" id="title" name="title" style="width:400px;"/>
</td>
</tr>

<tr>
<td>内容:</td>
<td>
<textarea rows="20" cols="54"></textarea>

</td>
</tr>

<tr>
<td></td>
<td>
<input type="button" id="submit_button" value="Click Me"/>
</td>
</tr>

<tr>
<td></td>
<td></td>
</tr>
</table>
</form>
<hr>
-- design by <a href="http://www.nodebook.info" target="_blank">Eddy</a>

</div>




</body>
</html>





[img]http://dl2.iteye.com/upload/attachment/0100/8262/a0f10805-bd00-3297-b9eb-8e36e7c8eac5.jpg[/img]


--
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值