您的位置:首页 > Web前端 > JavaScript

JS仿 WINXP 注销桌面渐隐效果

2007-06-14 11:36 309 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style>
body{margin:0;padding:0;}
#topFill{display:none;text-align:center;position:absolute;z-index = 999;filter:alpha(opacity=50);background-color:#eee;opacity: 0.5;-moz-opacity: 0.5;width:100%;}
#alertBox{margin:auto;height:150px;width:300px;background-color:#cf0;text-align:left;border:1px solid #666}
#alertTitle{height:20px;background-color:#EDF8B8;line-height:20px;padding:0 10px;border-bottom:1px solid #71860D}
#alertContent{padding:42px 0;;text-align:center;}
#alertBtn{text-align:center;}
  #alertBtn input{margin:0 10px;background:#FFFF99;border:1px solid #fff;height:20px;line-height:20px;}
</style>
<script type="text/javascript" >
//document.documentElement.clientHeight+'px'
//  onload的时候声明对象
var obj = new Object;
function oload(){
obj = document.getElementById('topFill');
obj.style.display = 'none';
}
function cl(){
document.body.style.overflow = 'hidden';
document.body.style.height = document.documentElement.clientHeight + 'px';
obj.style.display = 'block';
obj.style.height = document.documentElement.clientHeight + 'px';
}
function bcl(){
document.body.style.overflow = '';
obj.style.display = 'none';
}
function oresize(){
if(obj.style.display != 'block'){
  
}else{
  cl();
}
}
function isno(str){
if (str == 'yes'){
  window.close();
}else {
  bcl();
}
}
</script>
</head>
<body onload="oload()" onresize="oresize()">
<div id="topFill">
<div id="alertBox">
  <div id="alertTitle">警告!</div>
  <div id="alertContent">你确定要退出吗?</div>
  <div id="alertBtn"><input type="button" value="是(Y)" onclick="isno('yes')" /><input type="button" value="否(N)" onclick="isno('no')" /></div>
</div>
</div>
<input type="text" id="textaaa" />
<input type="button" value="点我" onclick="cl()"/>
<h1>呵呵阿斗司法</h1>
<p>呵呵阿斗司法</p>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1><h1>呵呵阿斗司法</h1><h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h
4000
1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
<h1>呵呵阿斗司法</h1>
</body>
</html>

页面里面总共有三个 按钮的 onclick 事件 和一个  body 的 onresize 事件

当点击   '点我' 那个按钮的时候. js就执行 cl 这个函数

[Copy to clipboard] [ - ]
CODE:
function cl(){
document.body.style.overflow = 'hidden';
document.body.style.height = document.documentElement.clientHeight + 'px';
obj.style.display = 'block';
obj.style.height = document.documentElement.clientHeight + 'px';
}

这个函数的意义就是  

我让   body 这个标签的 overflow 属性改为  ' hidden ' 很明显,就是让在body高度以外的 内容隐藏...嘿嘿......

下一行 的意思也就足够明显啦..   让 body的高度 = 当前窗体的高度~~ 这样由于 body 的 overflow  = 'hidden' 了..那么我给 body一个当前窗体的高度的化,那么 滚动条不就消失了吗??嘿嘿嘿...这样给我下一步的阴谋创造了条件哦.~~~

obj.style.display = 'block';这一句就是 让遮罩层显出来拉~~然后在给遮罩层一个高度,这个高度就是 窗体的高度~~这样的话..HOHO.......

这就让文档所有的内容 都盖到 遮罩层下面啦..~~~

然后 在给 body 的 onresize(当窗体大小改变时触发的事件) 一个函数 就是判断 遮罩层当前是否显示啊..如果显示的话就改遮罩层的大小等于当前窗体大小.否则什么都不执行...HOHO

到这里大家应该很清楚了吧
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息