0 votes


when playing a game in HTML5 Export, I'd like the game to first close a connection to a database before exiting if you're closing the tab in your browser (or just do anything, really - but I would like to call some functions before immediately quitting into the void).
Is there any way to handle such a request? Because I don't think that the standard windows notification-handling helps me out here, and I'm not sure if a custom HTML page would do it.

Godot version 3.3
in Engine by (17 points)

It's possible that quitting on an HTML5 export is handled differently than on other platforms. I couldn't find anything about this so it may be helpful to request documentation about it by opening an issue on GitHub.

1 Answer

0 votes

Godot currently doesn't have a built-in way to add an onbeforeunload handler, but this can likely be added yourself by calling JavaScript code from GDScript.

by (12,495 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.