点击弹窗提示,3秒后关闭窗口并跳转新的页面

<!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" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>Document</title>
<script type="text/javascript" src="jquery-1.8.3.min.js"></script>

<style type="text/css" >
/*灰色遮罩层*/
.fade{
width:100%;
height:100%;
background:rgba(0, 0, 0, 0.5);
position: fixed;
left: 0;
top: 0;
z-index: 99;
}
/*弹出层*/ 
.succ-pop{
width: 400px;
height: 300px;
background: #fff;
position: fixed;
left: 50%;
top: 50%;
margin-left: -200px;
margin-top: -150px;
z-index: 999;
border-radius: 5px;
} 
.succ-pop h3.title{
text-align: center;
font-size: 22px;
color: #ce002c;
}

</style>
<script>
function showDiv(){
$("#fade").show();
$("#pop").show();
setTimeout(function(){
//var windowOpen = window.open("http://www.baidu.com");
//if (windowOpen == null || typeof(windowOpen)=='undefined'){
//$('#feedback').html('新窗口无法打开,请检查你的浏览器设置。')
window.location.href="http://www.baidu.com";
}    
hideDiv();
}, 3000);
}
function hideDiv(){
$("#fade").hide();
$("#pop").hide();
}
</script>
</head>
<body>

<div class="fade" id="fade" style="display:none"></div>
<div class="succ-pop" id="pop" style="display:none">
<h3 class="title">
提示文字
</h3>    
</div>

<input id="show" type="button" readonly="readonly" value="点击显示" onclick="showDiv()"/>

</body>
</html>
  
View Code
原文地址:https://www.cnblogs.com/peteremperor/p/9953488.html