检测Javascript中的浏览器刷新 [英] Detect Browser Refresh in Javascript

查看:86
本文介绍了检测Javascript中的浏览器刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇是否有一种方法可以专门检测javascript中的浏览器刷新事件.我们正在使用jQuery.address插件为AJAX函数提供前进和后退按钮功能.我面临的问题是该插件似乎无法检测用户是否刷新了页面.

I am curious if there is a way to detect the browser refresh event in javascript specifically. We are using the jQuery.address plugin to provide forward and back button functionality to AJAX functions. The problem I am facing is that this plugin does not seem to detect if the user has refreshed the page.

每次用户在浏览器历史记录中前进或后退时都会执行此代码.我还希望它在用户刷新时消失.

This code is executed each time the user moves forward or back in the browser history. I would also like it to exexute when the user refreshes.

 $.address.init(function(event) {
}).change(function(event) {

        SummaryDiv.SwapPanels(newPanelID);
    }

有什么想法吗?

推荐答案

我的天真尝试是在每次更改后将当前状态简单地存储到某些cookie中,并在每次页面加载时再次将其重新加载.

A naive attempt of mine would be to simply store the current state into some cookie after each change and simply load them again on each page load.

这篇关于检测Javascript中的浏览器刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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