<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type="text/css">
.window{
width:250px;
background-color:#d0def0;
position:absolute;
padding:2px;
margin:5px;
display:none;
}
.content{
height:150px;
background-color:#FFF;
font-size:14px;
overflow:auto;
}
.title{
padding:2px;
color:#0CF;
font-size:14px;
}
.title img{
float:right;
}
</style>
<script type="text/javascript" src="/selfservice/front/inc/index/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$("#btn_center").click(function () {
popCenterWindow();
});
});
</script>
</head>
<body onload="settime()">
<div style="width:600px;margin-left:auto;margin-right:auto;margin-top:160px;">
<input type="button" value="居中窗口" id="btn_center" />
</div>
<div class="window" id="center">
<div id="title" class="title"><img src="" alt="关闭" />温馨提示</div>
<div class="content">温馨提示:请先收好您的身份证!<span id="shijian"></span>
</div>
</div>
<script type="text/javascript">
//获取窗口的高度
var windowHeight;
//获取窗口的宽度
var windowWidth;
//获取弹窗的宽度
var popWidth;
//获取弹窗高度
var popHeight;
function init(){
windowHeight=$(window).height();
windowWidth=$(window).width();
popHeight=$(".window").height();
popWidth=$(".window").width();
}
//关闭窗口的方法
function closeWindow(){
$(".title img").click(function(){
$(this).parent().parent().hide("slow");
});
}
//定义弹出居中窗口的方法
function popCenterWindow(){
init();
//计算弹出窗口的左上角Y的偏移量
var popY=(windowHeight-popHeight)/2;
var popX=(windowWidth-popWidth)/2;
//设定窗口的位置
$("#center").css("top",popY).css("left",popX).slideToggle("slow");
closeWindow();
}
var countdown=6;
function settime() {
if (countdown == 0) {
alert("时间到");
} else {
document.getElementById("shijian").innerHTML=countdown;
countdown--;
setTimeout(function() {
settime()
},1000)
}
}
//首页的时间设置
function settimeindex() {
document.getElementById("shijian").innerHTML=countdown;
countdown--;
setTimeout(function() {
settime()
},1000)
}
</script>
</body>
</html>
倒计时自定义弹出界面
猜你喜欢
转载自blog.csdn.net/yangjueye/article/details/80769038
今日推荐
周排行