2

I have written below code in javascript:

javascript code:

var fs=null;

        function initFS() {
            window.requestFileSystem =window.requestFileSystem || window.webkitRequestFileSystem;
               window.requestFileSystem (window.TEMPORARY, 1024 * 1024, function (filesystem) {
                fs = filesystem;
            }, errorHandler);
        }

html code:

<input type="button"  id="button2" name="click" value="show" onclick="initFS();" />

but after clicking on show button in initFS function, after line window.requestFileSystem (window.TEMPORARY, 1024 * 1024, function (filesystem) {
it is showing error as "uncaught type error". Is there any mistake in my code?

Shikha
  • 339
  • 2
  • 13

1 Answers1

0

You can not define errorHandler

var fs=null; 


        function initFS() {
            window.requestFileSystem =window.requestFileSystem || window.webkitRequestFileSystem;
               window.requestFileSystem(window.TEMPORARY, 1024 * 1024, function (filesystem) {
                fs = filesystem;
                console.log(fs);
            }, errorHandler);
        }
        function errorHandler(e) {
           console.log(e); // it show everything that you want 
          }
Man Programmer
  • 5,150
  • 2
  • 17
  • 18
  • @Shikha: can you tell what console print – Man Programmer Jul 26 '14 at 07:31
  • Console prints "FileError is deprecated. Please use the 'name' or 'message' attributes of DOMError rather than 'code' – Shikha Jul 26 '14 at 10:07
  • read this answer http://stackoverflow.com/questions/24930403/writing-to-a-file-in-javascript-using-filesystem-api may be it helps instead of FileError use name and message attributes – Man Programmer Jul 26 '14 at 13:37
  • -I have done as per given link by you but still the type error is coming. Is any other solution? – Shikha Jul 28 '14 at 10:55