I'm making an export function to a HTML5 game of mine and my current saving method is a crude serialization of game data and then:
// this is Javascript
var gameData = "abc"; // this is actually a HUGE string of over 2MB
try
{
document.location = "data:text/octet-stream,"+encodeURIComponent(JSON.stringify(gameData));
}
catch(e)
{
console.log(e);
}
From: Using HTML5/Javascript to generate and save a file
I don't mind the fact that I can't use it for big strings, but I'd like it to generate a warning that informs that this method doesn't work, unfortunately Chrome (16) crashes without catching that exception.
Is there a better way to implement this kind of export, the important thing being for me is to make it work locally. FileAPI would be a better solution, but doesn't work locally.