Sign in
Log inSign up

How to prevent reload and show custom popup ?

ananth subbu's photo
ananth subbu
·Dec 31, 2018

My application is developed in react. I have a form , when my user tries to reload I have to disable brower's
default popup and show my own custom popup.

I tried with "onbeforeunload" and "beforeunload" events , I can able to prevent brower's default popup by giving window.onbeforeunload = null;

But I have to prevent brower's default alert and show my custom alert with ok and cancel button.

Is there anyway I can detect my brower is getting reloaded ?

Can someone help me on this.Thanks in advance.

Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct