前端页面自动加载下一个文件
下面是我找的并且修改的前端页面:
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<body>
<div style="margin:50px auto 0;width:360px;">
<button type="button" onclick="myFresh();" id="timeFresh" class='btn btn-mini btn-info'>关闭自动</button>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/JavaScript">
var i=0;
var timer=null;
var status='N';
$(document).ready(function(){
myFresh();
});
function myFresh(){
if(status=='Y'){
i=0;
status='N';
clearInterval(timer);
}else if(status=='N'){
status='Y';
timer=setInterval(function(){
i++;
if(i==1){
clearInterval(timer);
location.reload();
}
},1000);
}
}
</script>
</body>
</html>
这个是我的作品成形的:
前端:
<button type="button" class="roll-nav" onclick="myFresh()" id="D">
<i class="fa fa-play fa-2x"></i>
</button>
function myFresh() {
if (status == 'Y') {
i = 0;
status = 'N';
clearInterval(timer);
} else if (status == 'N') {
status = 'Y';
timer = setInterval(function () {
i++;
if (i == 360) {
clearInterval(timer);
//这是一个抓取最新文件的ajax,后台自写
$.ajax({
url: prefix + "/findYear",
type: "post",
data: {"type": type},
cache: true,
success: function (result) {
if (themeLayer != undefined) {
themeLayer.remove();
}
if (polygon != null) {
polygon.remove();
popup.remove();
}
$("#orgName").val(result[0]);
createTheme(type, result[0]);
}
});
}
}, 1000);
}
}