http://www.ajaxbbs.net/ymPrompt2.0/#entrymore
<SCRIPT language="javascript">
<!--
function lock(menu) //锁定函数
{menu.style.display="none"?'':''; //打开蒙版
document.cookie="lock=yes"; //设置cookies,使锁定长期有效,
lockpwd.focus(); //密码框直接获取焦点
}
function unlock(menu) //解锁函数
{
menu.style.display=""?'none':'none'; //去除蒙版,达到解锁
document.cookie="lock=no"; //设置cookie
return false;
}
function cklock() //对输入的密码进行验证
{
if (lockpwd.value==getcookie('lockpwd')) //验证密码与cookie密码
{ unlock(lockform);}
else
{alert("密码错误,请重新输入!");
lockpwd.value="";
lockpwd.focus();
return false;}
}
function getcookie(name) //获取cookies,用来验证输入的密码
{
var aCookie = document.cookie.split("; "); //取得所有cookies,并放置到数组中:[cookie名=值]
for (var i=0; i < aCookie.length; i++) //遍历所有cookies
{
aCrumb = aCookie[i].split("="); //将cookie名和值分开
if (name==aCrumb[0]) //验证cookie名
{ return aCrumb[1]; } //返回cookie值
}
}
-->
</script>
<style>
<!--
body{overflow-y:visible;overflow-x:visible; }
body,div,input{text-align:center;font-size:10pt;font-face:微软雅黑;}
input{height:20;}
#lockbtn{float:left;margin-left:50px;cursor:hand;}
#lockform,#locklayer{
position: absolute;
width:expression(this.parentNode.scrollWidth);
top:expression(this.parentNode.scrollTop);
left=0; height:100%;right:0; bottom:0;
}
#lockform { z-index:1}
#locklayer{ z-index:1;background-color:#AAA;filter:alpha(opacity=50);}
#locktab{
position: absolute;
top:250px;left:expression(this.parentNode.scrollWidth/2-100);
background-color:#FDFEFF; z-index:2;width:200px;height:60px;
border-style: solid; border-width: 1px;border-color:green;color:red;
}
#lockck{border:0;background:fff;color:red;}
-->
</style>
<body>
<div id="lockbtn" οnclick="lock(lockform);">锁定</div>
<div id="lockform" style="display:none;">
<div id="locklayer"></div>
<div id="locktab">
<input id="lockck" type="submit" value="请输入解锁密码:" οnfοcus="cklock();" >
<div><input id="lockpwd" type="password" name="lockpwd" οnfοcus="this.value=''" size=16></div>
</div>
</div>
</body>