how to redirect to another web-page on browser refresh. I know people will say its a bad thing but it is quite necessary for me, so please ca you tell me how to redirect the user to another webpage on refresh.
Asked
Active
Viewed 1,029 times
0
-
By `on browser refresh` do you mean when someone presses Reload or f5? – CertainPerformance Apr 15 '18 at 20:02
-
any form of refresh. reload/f5 . I know we can customise the f5 button i want to focus on esp browser reload icon click – roh_dev Apr 15 '18 at 20:04
1 Answers
2
Check performance.navigation
to see if the page has just been refreshed, and if it has, just assign to window.location.href
accordingly:
if (performance.navigation.type === 1) {
// page was just refreshed:
window.location.href = 'https://some-redirect';
} else {
// rest of your Javascript
}

CertainPerformance
- 356,069
- 52
- 309
- 320
-
-
-
@SanalKv this has an idea for Flutter web https://stackoverflow.com/questions/73053668/flutter-web-how-to-redirect-to-root-page-or-any-other-page-when-browser-is-r?noredirect=1&lq=1 – saintjab Aug 31 '23 at 21:33