将警报中的“确定”按钮设置为运行location.reload方法

Set the OK button in an alert to run location.reload method

本文关键字:设置 运行 location 方法 reload 按钮 确定      更新时间:2023-09-26

如何调用警报消息框中的OK按钮来运行location.reload()?我的页面上有另一个按钮,我不想在下面运行此函数,只调用此方法的警报按钮的最佳方式是什么?

$('button')location.reload(true)

一种有效的方法是通过调用confirm()来执行重载。

var _confirm = confirm("confirmation message");
if (_confirm) {
window.location.reload();
}