Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The File Dialog page in the Wiki mentions a <a href="https://github.com/rogerwang/node-webkit/wiki/File-dialogs#other-types-of-dialogs" rel="nofollow">save dialog file input</a></p> <blockquote> <p>nwsaveas will open a save as dialog which let user enter the path of a file, and it's possible to select a non-exist file which is different with the default file input tag:</p> </blockquote> <p>You could use that in an custom dialog like a modal or so to query the user for that input.</p> <p>Very basic example based on your provided code:</p> <pre><code>&lt;script&gt; var fs = require('fs'); var buildFile = function(name, value) { var img = new Buffer(value, 'base64'); fs.writeFile(name, img, function(err) { if(err) { console.log(err); } else { console.log("The file was saved!"); } }); } function wait() { $('#close-popup').click(); setTimeout(function() {screen_shot()}, 10); } function screen_shot() { html2canvas($('body'), { onrendered: function(canvas) { var img = canvas.toDataURL("image/png").split(',')[1]; var decodedImg = window.atob(img); query_for_save_path(function (save_path) { buildFile(save_path, img); alert('Screenshot saved to: ' + save_path); }); } }); } function query_for_save_path(cb) { $('#dialog').show(); $('#dialog input').one('change', function (event) { cb($(this).val()); }); } &lt;/script&gt; &lt;a href="#" onclick="wait();" data-role="button" data-theme="j"&gt;Screen shot&lt;/a&gt; &lt;div id="dialog" style="display:none;"&gt; Choose a path to save your shot: &lt;input type="file" nwsaveas /&gt; &lt;/div&gt; </code></pre>
 

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