JS 刷新当前页面,JS 延迟跳转,HTML 弹出提示

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>
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值