您的位置:首页 > 其它

弹出层并屏蔽父窗口(防刷新、后退、关闭窗口)

2008-08-26 15:15 351 查看
<script type="text/javascript" language="javascript">
document.onmouseover=function(){
if(event.srcElement.id != "tijiao"){
window.onbeforeunload = function(){
return "如果您离开本页面,那么您本次的操作将视为无效!";
}
}
else{
window.onbeforeunload = null;
}
};
function ShowNo() //隐藏两个层
{
document.getElementById("doing").style.display="none";
document.getElementById("loading").style.display="none";
}
function $(id)
{
return (document.getElementById) ? document.getElementById(id) : document.all[id] ;
}
function showFloat() //根据屏幕的大小显示两个层
{
var range = getRange();
$('doing').style.width = range.width + "px";
$('doing').style.height = range.height + "px";
$('doing').style.display = "block";
document.getElementById("loading").style.display="";
}
function getRange() //得到屏幕的大小
{
var top = document.body.scrollTop;
var left = document.body.scrollLeft;
var height = document.body.clientHeight;
var width = document.body.clientWidth;

if (top==0 && left==0 && height==0 && width==0)
{
top = document.documentElement.scrollTop;
left = document.documentElement.scrollLeft;
height = document.documentElement.clientHeight;
width = document.documentElement.clientWidth;
}
return {top:top ,left:left ,height:height ,width:width } ;
}
</script>
<style type="text/css">
body{margin:0px;}
</style>

<form id="form1" runat="server">
<a id="tijiao" href="javascript:void(0)" onclick="showFloat()">提交</a>
<div style="margin:auto;height:500px; width:300px;text-align:center;line-height:500px;">此处添加表单信息</div>

<!--加一个半透明层-->
<div id="doing" style="filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3;background-color:#000;width:100%;height:100%;z-index:1000;position: absolute;left:0;top:0;display:none;overflow: hidden;">
</div>
<!--加一个等待层-->
<div id="loading" style="border:solid 10px #898989;background:#fff;padding:10px;width:780px;z-index:1001; position: absolute; display:none;top:50%; left:50%;margin:-200px 0 0 -400px;">
<div style="padding:3px 15px 3px 15px;text-align:left;vertical-align:middle;" >
<div>
数据正在请求中,请稍等...
</div>
</div>
</div>
</form>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: