Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is a little tricky but working</p> <pre><code>chrome.browserAction.onClicked.addListener(createFile); createFile(); function createFile() { chrome.tabs.getSelected(null, function(tab) { window.webkitRequestFileSystem(window.TEMPORARY, 1024*1024, function(fs) { fs.root.getFile('test', {create: true}, function(fileEntry) { 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() { chrome.tabs.create({"url":fileEntry.toURL(),"selected":true},function(tab){}); }; 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; }; Console.Log('Error: ' + msg); } </code></pre> <p>Because of the Security Exceptions, i cannot create/modify a file on Local System. But in this code, I am actually creating a file in a directory which is allocated for Google Chrome Temporary Files and then downloading that file into my Downloads Folder.</p> <p>This is the code of the popup page of a Chrome Extension.</p> <p>:)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload