0

i´m currently using JavaScript and HTML with eel and Python. But unfortunately when I am trying to create a file in the Chrome-Browser window (as an download) over JS i can only download it once. The second "download" is not working.

-> Chrome just shows this (as it does when it downloads something) but then nothing happens: enter image description here

When I am using Edge browser or only JS without eel it works perfectly fine!

My JS function that creates the download: (string is a json string that is generated earlier).

  var jsonLink = document.getElementById("jsonLink");
  jsonLink.download = "exportedToJson.json";
  jsonLink.href = "data:application/json;charset=utf-8," + encodeURIComponent(string);
Fabi0
  • 131
  • 2
  • 5
  • Welcome to StackOverflow! A little more information might help us provide guidance. For example, how is the second download "not working"? Is there an error? Does it just hang? Also, in your code example, where is `string` assigned, and to what is it assigned? A _really_ useful thing would be if you could provide a [minimal reproducible code example](https://stackoverflow.com/help/minimal-reproducible-example) with Python, HTML, and JavaScript code snippets. – dstricks Aug 03 '21 at 18:30
  • Thanks for the updated information... I'll take a look. One possible workaround (not a final solution), is that you can have Eel open up in Edge instead of Chrome. You can pass the `mode` argument to the `eel.start(...)`. Something like `eel.start('index.html', mode='edge')`. – dstricks Aug 05 '21 at 01:01
  • Thanks! I´m currently using this and it works fine so far. But later on I am trying to convert my application into an exe file via pyinstaller -> that does show an error with edge, but works with chrome ... – Fabi0 Aug 05 '21 at 05:47

1 Answers1

0

Ok I found a solution:

My chrome browser was blocking more than one download from "localhost:8000". So I had to go to settings and allow more than one download.

Maybe this helps someone :)

Why did I not find this earlier: When I started my Python script, it calls:

eel.start('index.html', mode='chrome', port=8000) #starting chrome

Which does open a new Chrome Tab without the Tabbar (so i did neither see the tabs nor my favorite sites). Therefore I did not get a notification when chrome stated that download is blocked. But after starting the eel-local webserver and open localhost:8000 in my normal chrome window, I did get a notification and I was able to allow the downloads. -> afterwards it also worked in this eel-chrome window.

Fabi0
  • 131
  • 2
  • 5