Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Question [Help] How can I show an exit popup in a specific case?

Discussion in 'Web' started by hwk9120, Jul 7, 2023.

  1. hwk9120

    hwk9120

    Joined:
    May 9, 2023
    Posts:
    17
    Hi, I want to show an exit popup by using onbeforeunload like below.

    Code (JavaScript):
    1. <script>
    2.     window.onbeforeunload = function () {
    3.         if (specific case) return "show popup"; // show popup and then close window.
    4.         else return "";  // just close window
    5.     }
    6. </script>
    But the specific case what I want is a global variable(bool) on a C# script (This script is a singleton instance).
    How can I get this C# script variable state in the index.html?
     
  2. hwk9120

    hwk9120

    Joined:
    May 9, 2023
    Posts:
    17