如何使用jquery或javascript重新加载或刷新页面? [英] How to check page is reloading or refreshing using jquery or javascript?

查看:115
本文介绍了如何使用jquery或javascript重新加载或刷新页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在页面刷新或重新加载时进行某种操作。那是我点击下一页或过滤或刷新网格时。我需要在此活动上显示一些确认框。

I have to do some kind of operation on the page refresh or reload. that is when I hit next page or Filter or refresh on the grid. I need to show some confirmation box over this Events.

是否有任何事件可以告诉你页面在做文件管理器?刷新或分页?使用javascript?

is there any event which can tell you page is doing filer? refresh or paging? using javascript?

谢谢

推荐答案

如果它令人耳目一新, 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?";
}

这篇关于如何使用jquery或javascript重新加载或刷新页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆