I am trying to show a custom popup when I refresh a specific page in Chrome (or any browser). Since we can't change the default message like Reload site? Changes you made may not be saved
, I need to totally replace the popup.
...
mounted() {
window.addEventListener('beforeunload', this.beforeUnload)
},
methods: {
async beforeUnload(event) {
// this.showReloadPopup = true // This doesn't work for the first time. It only works after the default popup
event.preventDefault()
event.returnValue = ''
},
},
...
As you can see the above code, this.showReloadPopup = true
doesn't work. It only works after the default popup.
beforeRouteLeave(to, from, next) {
this.nextRoute = next
next(false)
this.showReloadPopup = true
},
And the beforeRouteLeave
works only when the page is navigated.
Is there a similar hook like beforeRouteReload
or else?
Otherwise, is there any way to know if the reload button is clicked from the default popup?