'Can I use onbeforeunload as an event for a script?
So i wanted to make a small game in javascript to be seen in the browser which includes a database, an user would connect and before he leaves the page would forward the progress of his account on said database.
I visited this question : window.onunload is not working properly in Chrome browser. Can any one help me?
And this one : what can i put in beforeUnload?
Which provided information on unload not being as good as onbeforeunload, returning a string rather than an alert.
I have problems with onunload/onbeforeunload events (before making links with the database i tried just having an alert/returning a string to have a message from the browser : seeing an output from event) which don't seem to work on chrome/safari.
For instance this code only trigger a response on my code editor (Komodo) but no browsers :
window.onbeforeunload = function(){return "Are you sure you want to leave this page?";}
So in the end should i just try with the database to see if i can have a script working in onbeforeunload ?
If anyone has an idea/a solution I would enjoy it very much :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
