1

Possible Duplicate:
window.requestFileSystem not working

Following is the code to generate a csv file using any data from HTML page. In my case, I hvae a variable history in which I have data collected from a HTML table.

By this code, I can download the generated csv file in my computer. this code is working fine in Google Chrome but not in Firefox. I need to run it in firefox too.

This code is from HTML5

You can try this code here

window.webkitRequestFileSystem(window.TEMPORARY, 1024*1024, function(fs) {
        fs.root.getFile('history_tracker.csv', {create: true}, function(fileEntry) {
          fileEntry.createWriter(function(fileWriter) {
            var builder = new WebKitBlobBuilder();

            builder.append(history);

            var blob = builder.getBlob('text/plain');

            fileWriter.onwriteend = function() {
              window.open(fileEntry.toURL());
            };
            fileWriter.write(blob);
          }, errorHandler);
        }, errorHandler);
      }, errorHandler);
    }

    function errorHandler(e) {
      var msg = '';

      switch (e.code) {
        case FileError.QUOTA_EXCEEDED_ERR:
          msg = 'QUOTA_EXCEEDED_ERR';
          break;
            case FileError.NOT_FOUND_ERR:
          msg = 'NOT_FOUND_ERR';
          break;
            case FileError.SECURITY_ERR:
          msg = 'SECURITY_ERR';
          break;
            case FileError.INVALID_MODIFICATION_ERR:
          msg = 'INVALID_MODIFICATION_ERR';
          break;
            case FileError.INVALID_STATE_ERR:
          msg = 'INVALID_STATE_ERR';
          break;
            default:
          msg = 'Unknown Error';
          break;
                };
      }
Community
  • 1
  • 1
Saurabh Saxena
  • 3,005
  • 10
  • 31
  • 46

3 Answers3

2

You're using a nonstandard API: the filesystem API. It's not part of HTML5, and may not ever become standardized; right now it's just a proprietary Chrome extension to the standards.

Boris Zbarsky
  • 34,758
  • 5
  • 52
  • 55
1

I assume that since the function is called window.webkitRequestFileSystem(), that it isn't part of the HTML5 standard. The webkit engine is only used by a few browsers including Safari and Chrome, but not Firefox. You'll want to lookup the API offered by Firefox.

Nadir Muzaffar
  • 4,772
  • 2
  • 32
  • 48
0

Chrome is currently the only browser to implemented the HTML5 Filesystem API. See the supported browsers note in the html5rocks article.

ebidel
  • 23,921
  • 3
  • 63
  • 76