search

Home  >  Q&A  >  body text

javascript - How to pop up a self-implemented pop-up window when closing the browser window?

I checked a lot of information and found out that there is a onbeforeunload method, which is triggered when the tab is closed. If the return value is string (true/false will also be converted to string), the browser's default pop-up window will be called. Prompt the return value (but in fact, the new version of the browser has ignored the return value and directly uses the browser's default prompt statement)

But I think some companies can pop up a custom pop-up window when closing a tab, such as the promotional advertisement of Ve, I have seen it implemented.

Ve’s demonstration link, there is a demonstration at 1:30 seconds of closing the browser to pop up a custom pop-up window

I don’t know if you have encountered similar needs or have any good ideas. You can also mention them. Thank you everyone~

世界只因有你世界只因有你2745 days ago829

reply all(1)I'll reply

  • PHPz

    PHPz2017-05-19 10:15:25

    onbeforeunload Since it is a method, you can control the display of the custom pop-up window when this method is triggered

    reply
    0
  • Cancelreply