<script language="javascript">
//登陆弹出对话框,并使背景元素不可用
var div_width = 300
var div_height = 200
function showWindow(width,height){
location.href="#"
width = div_width
height = div_height
var windowstr= document.getElementById("popLayer").innerHTML
document.getElementById("infoDiv").innerHTML=windowstr
document.getElementById("infoDiv").style.left=((document.body.clientWidth-width)>0?(document.body.clientWidth-width):0)/2+"px"
document.getElementById("infoDiv").style.top=200+"px"
document.getElementById("infoDiv").style.zIndex=10001
document.getElementById("infoDiv").style.width=width
document.getElementById("infoDiv").style.height=height
document.getElementById("infoDiv").style.border="3px solid #0099ff"
document.getElementById("tranDiv").style.height=document.body.clientHeight+ "px"
document.getElementById("tranDiv").style.width=document.body.clientWidth+ "px"
document.getElementById("tranDiv").style.display=""
document.getElementById("tranDivBack").style.display=""
document.getElementById("tranDivBack").style.zIndex=10000
document.getElementById("infoDiv").style.display=""
}
function closeWindow(){
document.getElementById("tranDiv").style.display="none"
}
</script>
页面中:
<!--层遮罩部分-->
<div style="position:absolutedisplay:noneleft:0pxtop:0px" id="tranDiv">
<div style="position:absoluteleft:0pxtop:0pxwidth:100%height:100%background-color:#000000filter:alpha(Opacity=30)" id="tranDivBack"></div>
<div align='center'style='position:absoluteleft:0pxtop:0pxwidth:100%height:100%background-color:#e5edf5background-image:url(images/bestnetqywimg/tccbg.gif)' id='infoDiv'></div>
</div>
<!--层遮罩部分结束-->
<!--弹出层登录-->
<div id="popLayer" style="display:none"><form id="formdl" name="formdl" method="post" action=""><br /><font align="center" color="#0000ff" size="3"><b>---手机号码先登录---</b></font><br /><br />
<br/>
<input type="submit" name="Submit" class="bntccanniu" value="登录" /><input type="button" name="Submit1" class="bntccanniu" value="取消" onclick="closeWindow()"/>
</form>
</div>
<a href="javascript:">点击此处看看</a>
也就先做一个DIV。里面的内容都做好。此DIV背后加一个mask层。
把这个DIv默认设置为隐藏。
JS里加一个定时器,每隔一分钟,设置为这个DIv的css样式中的display=block
显示层:
css:
.showdiv
{
width: 100%
height: auto
position: absolute
left: 0
top: 0
z-index: 999
display: none
}
.count_div
{
width: 500px
height: 400px
margin-top: 120px
margin-left: auto
margin-right: auto
margin-bottom: 0
border: 1px solid #aaaaaa
background: #fff
}
.brg
{
width: 100%
background: #ededed
position: absolute
top: 0
left: 0
filter: alpha(opacity=60)
-moz-opacity: 0.6
opacity: 0.6
position: absolute
top: 0
left: 0
display: none
z-index: 998
}
js:
function close () {
$("#brg").css("display", "none")
$("#showdiv").css("display", "none")
}
function show() {
$("#brg").css("display", "none")
$("#div_show").css("display", "none")
}
$(document).bind('keydown', 'esc',function (evt){
//关闭层代码
close ()
return false})
html:
<!--遮罩层-->
<div class="brg" id="brg">
</div>
<!--显示层-->
<div class="showdiv" id="div_order">
<div class="count_div" id="div_order_count">
内容
</div>
</div>
在网上找一个“jquery.hotkeys.js”的js包,里面都是jquery整理好的热键,
引入jquery包。
$(document).bind('keydown', 'esc',function (evt){
//关闭层代码
return false})
手敲,未测试,应该不会有太大问题,根据自己内容修改