I have a Flash game that I'm trying to save the state of when the user closes the browser tab. It is using the following jquery code:
//Called from Flash when window closes
function sendRequest(url, params) {
$.ajax({
type: "POST",
async: false,
url: url,
data: params
})
}
$(window).unload(function() {
//Make Flash attempt to save the game when the window closes.
//Flash gets the necessary data and calls sendRequest()
document["flashGame"].saveBeforeUnload();
});
- Firefox: Works correctly
- Chrome: Works correctly when reloading but not when closing tabs or closing the browser
- IE (all versions): Does not work at all
I want it to work in all browsers correctly, but most important is Chrome (not many of our users have IE).
Flash is correctly calling sendRequest (in all browsers, tested with an alert), so I don't believe the problems come from Flash, but it might.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…