使用confirm来阻断<a>标签的跳转

首先a标签如下

<a href="javascript:delete_confirm('${pageContext.request.contextPath}/role/deleteRole.do?roleId=${role.roleId}')">删除</a>

该href是跳转到一个函数上,并在调用的时候传入路径参数,这样子就可以在我定义的函数中获取到点击“确定”后要跳转的url

//删除角色前的确定
    function delete_confirm(url) {
        if (confirm("确定删除该角色?")) {
            location.href = url;
        }
    }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
样式优化美化<!DOCTYPE html> {% load static %} <html> <head> <title>个人中心</title> <style> .container { display: flex; flex-wrap: wrap; justify-content: space-between; } .module { width: calc(25% - 20px); margin-bottom: 20px; padding: 20px; border: 1px solid #ccc; border-radius: 5px; } @media (max-width: 768px) { .module { width: calc(50% - 20px); } } @media (max-width: 480px) { .module { width: 100%; } } </style> </head> <body> <div class="container"> <div class="module personal-info"> <!-- 个人信息模块 --> <h2>个人信息</h2> <form> <label for="username">用户名:</label> <input type="text" id="username"> <label for="email">邮箱:</label> <input type="email" id="email"> <button type="submit">保存</button> </form> </div> <div class="module change-password"> <!-- 修改密码模块 --> <h2>修改密码</h2> <form> <label for="old-password">旧密码:</label> <input type="password" id="old-password"> <label for="new-password">新密码:</label> <input type="password" id="new-password"> <label for="confirm-password">确认密码:</label> <input type="password" id="confirm-password"> <button type="submit">保存</button> </form> </div> <div class="module bind-phone"> <!-- 绑定手机模块 --> <h2>绑定手机</h2> <form> <label for="phone">手机号:</label> <input type="tel" id="phone"> <button type="submit">保存</button> </form> </div> <div class="module my-messages"> <!-- 我的消息模块 --> <h2>我的消息</h2> <ul> <li><a href="#">系统消息1</a></li> <li><a href="#">系统消息2</a></li> <li><a href="#">好友消息1</a></li> <li><a href="#">好友消息2</a></li> </ul> </div> </div> </body> </html>
最新发布
06-09

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值