Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229600

Ionic and onbeforeunload

$
0
0

I'm trying to get the browser back button to be reasonable when running in a web browser. I'm defaulting to having no routes/deep-links, so the whole SPA is essentially the same URL. If the user clicks the back button (which is very normal), I want to just warn them that they're leaving the site.

I can hook up the onbeforeunload, and it does get hit, but unfortunately returning a text string doesn't trigger the normal visual warning. Is there anything in Ionic that's preventing this event from warning the user? Any other suggestions on warning on browser back button use?

window.onbeforeunload = () => {
    this.loggingService.info("user navigating away from page");

    //If user logged in, warn them before leaving
    if (this.auth.user) {
      return 'Leaving the site?  If not, please use the in-app navigation and not the back button.';
    }
}

Viewing all articles
Browse latest Browse all 229600

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>