Approach to detect if end user press F5 or refresh button
It is important to detect if end user press F5 or refresh button is very important for popular single page application. Becasue we need at the time to redraw whole layout. Recently implement it in project with below code,
window.onbeforeunload = function () { sessionStorage.setItem('refresh', true); };
var isRefreshingPage = function () { var oldState = sessionStorage.getItem('refresh'); sessionStorage.setItem('refresh', false); return oldState == 'true'; };
7 comments
[ 3.1 ms ] story [ 19.0 ms ] threadAlso, what happens when someone has 2 tabs open with the app, closes one and tries to do some action in the other?
Edit: What I really want to ask is... why is this ever necessary?