0

In Gmail when you are in middle of composing a email and attempt to navigate away from the page they pop up a confirm() dialog box The first line of the box is "Reload site?"

However when I use confirm('message') in the popup that is generated the first line of text always contains the text localhost says

From what I have seen the confirm() only has one parameter message

How is Gmail able to customize that text to say Reload site?

Dovid Gefen
  • 323
  • 3
  • 17
  • Possible duplicate of [How to call a function before leaving page with Javascript](https://stackoverflow.com/questions/28627111/how-to-call-a-function-before-leaving-page-with-javascript) – VLAZ Jun 17 '19 at 14:56

1 Answers1

0

Gmail uses window.onbeforeunload which bypasses the security restriction of showing the sites domain and instead replaces it with a context specific header.

window.onbeforeunload = () => 'some message'

Mbrevda
  • 2,888
  • 2
  • 27
  • 35