Close Button

The close button is an optional UI element that allows users to exit the THNDR experience from within the game. Because THNDR is embedded inside your host application, the close button communicates back to your app via postMessage. Your app is then responsible for deciding what to do (close the iframe, navigate away, etc.).

Enabling the close button

The close button is shown by default. If you'd like to disable it, let your THNDR integration contact know.

postMessage event

When the user clicks the close button, the game emits the following message to the parent window:

{
  "message": "operator_redirect",
  "data": {
    "name": "close"
  }
}

Your host application should listen for this message and respond accordingly, typically by closing or hiding the game, or redirecting the user to another screen.

Example listener

window.addEventListener("message", (event) => {
  if (
    event.data?.message === "operator_redirect" &&
    event.data?.data?.name === "close"
  ) {
    // Close or hide the iframe
    document.getElementById("thndr-iframe").style.display = "none";
  }
});

Confirmation popup (optional)

An optional confirmation popup can be shown when the user clicks the close button, prompting them to confirm before exiting. This is useful if you want to prevent accidental exits mid-session.

This behaviour is off by default. If you'd like it enabled, request this when setting up the close button with your THNDR integration contact.

When the confirmation popup is active, the postMessage event is only sent after the user confirms they want to leave, not on the initial button click.

Last updated