且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用jquery或javascript重新加载或刷新页面?

更新时间:2022-02-03 04:31:22

如果它令人耳目一新, window.onunload 将触发。

If it is refreshing, window.onunload will fire.

// From MDN
window.onunload = unloadPage;
function unloadPage()
{
    alert("unload event detected!");
}

https://developer.mozilla.org/en/DOM/window.onunload

如果您只是想要确认允许他们留下来的盒子,使用这个:

If you just want a confirmation box to allow them to stay, use this:

window.onbeforeunload = function() {
    return "Are you sure you want to navigate away?";
}