This code is working fine on jsFiddle but not on my system. JsFiddle
I have checked from the draft (Pressing Ctrl + Shift + Enter on jsFiddle), added this code to head section & modified like below:
window.addEvent('load', function() {
window.webkitRequestFileSystem(window.TEMPORARY, 2*1024*1024, function(fs) {
fs.root.getFile('test', {create: true}, function(fileEntry) {
alert(fileEntry.toURL());
fileEntry.createWriter(function(fileWriter) {
var builder = new WebKitBlobBuilder();
builder.append("Saurabh");
builder.append("\n");
builder.append("Saxena");
var blob = builder.getBlob('text/plain');
fileWriter.onwriteend = function() {
// navigate to file, will download
location.href = fileEntry.toURL();
};
fileWriter.write(blob);
}, function() {});
}, function() {});
}, function() {});
});