rg443

download generated file client side

Oct 26th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var blob = new Blob([JSON.stringify(photos)], {"type": "application/json"});
  2. var link = document.createElement("a");
  3. if(link.download !== undefined) {
  4.   link.setAttribute("href", window.URL.createObjectURL(blob));
  5.   link.setAttribute("download", "photos1.json");
  6.  }
  7. else {
  8.   link.setAttribute("href", "http://www.example.com/export");
  9. }
  10. link.click();
Add Comment
Please, Sign In to add comment