两个Java代码,帮忙看看怎么整合
jquery吧
全部回复
仅看楼主
level 1
学而有崖 楼主
下面是两个JAVA代码,要求实现的是键盘鼠标5分钟无操作,弹出30秒倒计时窗口,然后秒结束后AJAX提交代码跳转,30秒内点击确定,无动作。
1
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.info{}
</style>
<script type="text/javascript" src="js/jquery.js"></script>
<script>
var times = 0;//5分钟 = 300000 毫秒
var ss = setInterval("doPost()", 1000);
$(function(){
$(document).on("mousedown keydown", function(){
clearInterval(ss)
});
});
function doPost(){
times += 1000;
console.info("into doPost times=" + times);
if(times >= 5000) {
var url = "http://www.baidu.com";
$.ajax(url,{
type:"post",
url:url,
}).done(function(data){
console.info("success");
}).fail(function(){
console.info("ajax fail")
});
clearInterval(ss)
}else {
console.info("还没到时间呢")
}
}





2



倒计时


body{
padding:0;
margin:0;
}
.dd{
position:fixed;
z-index:1;
width:30%;
height:240px;
background:#eee;
top:30%;
left:30%;
border-radius:10px;
display:none;
}
.d{
position: absolute;
border-radius:5px;
background:green;
width:100px;
height:40px;
color:#fff;
text-align:center;
border:0;
left:42%;
bottom:15px;
}
b{
color:red;
}
.c{
position: absolute;
text-align:center;
bottom:120px;
left:42%;
}



3秒后弹出提示框


30秒后将跳转

确定



$(function(){
var iv1;
var to1;
var iv2;
iv1 = setInterval(function(){
$("<a href="https://tieba.baidu.com/mo/q/hotMessage?topic_id=0&fid=896836&topic_name=s1&quot;).text(Number($(&quot;&is_video_topic=0">#s1&quot;).text(Number($(&quot;#</a>s1").text())-1);
if($("#s1").text() == "0"){
clearInterval(iv1);
}
},1000);
to1 = setTimeout(function(){
$(".dd").fadeIn("slow");
iv2 = setInterval(function(){
$("#s2").text(Number($("#s2").text())-1);
if($("#s2").text() == "0"){
clearInterval(iv2);
window.location.href="http://www.baidu.com";
}
},1000);
},3000);
if($(".dd").css("display")=="block"){
clearTimeout(to1);
}
$(".d").click(function(){
if($("#s2").text() != "0"){
$(".dd").hide();
clearInterval(iv2);
}
});
});
</script>
</html>
2016年07月15日 15点07分 1
1