JS刷新当前页面
方法一
reload()方法用于刷新当前页面
reload() 方法类似于浏览器上的刷新页面按钮
location.reload();
方法二
replace() 方法可用一个新页面取代当前页面
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
function replaceDoc(){
window.location.replace("http://www.baidu.com")
}
</script>
</head>
<body>
<input type="button" value="载入新页面替换当前页面" onclick="replaceDoc()">
</body>
</html>
方法三
页面自动刷新:把如下代码加入<head>区域中,其中5指每隔5秒刷新一次页面
<meta http-equiv="refresh" content="5">
// 5秒后自动跳转页面
<meta http-equiv="refresh" content="5;url=//www.baidu.com">
<script language="JavaScript">
function myrefresh(){
window.location.reload();
}
setTimeout('myrefresh()',1000); //指定1秒刷新一次
</script>
JS延迟跳转
第一种
// 延迟2秒跳转
window.setTimeout("window.location='index.jsp'",2000);
第二种
// 延迟5秒跳转
jQuery(document).ready(function(){
setTimeout("window.location = 'index.jsp'", 5000);
});
// jQuery准备函数的全写
jQuery(document).ready(function() {});
// jQuery准备函数的缩写
$(function() {});
HTML弹出提示
第一种
<button type="button" class="btn btn-danger" onclick="del(${u.id })">删除</button>
<script type="text/javascript">
function del(id) {
if (confirm("您确定要删除吗?")) {
window.location = "${path}/user?method=del&id=" + id;
}
}
</script>
第二种
<a class="btn btn-danger"
href="javascript:if(confirm('确实要删除吗?'))location='${path}/user?method=del&id='+${u.id}">删除</a>