Skip to main content
Fix English syntax and remove emotional word.
Source Link
AmerllicA
  • 31.6k
  • 17
  • 141
  • 166

Hello I want to be able to download a given file when pressing a button.The file will be provided via an apiAPI call.For now i, I will have it in my local storage. So my folder is something like :

rootFolder
-jsJS file
-htmlHTML file
-download file (`sample.csv`)

How can I create a download link? I have tried so far with : <a download="sample.csv"></a> I have also tried using an onclick event:

<a download="sample.csv" onclick="download()"></a>

function download|(){
   .....code that calls the `api`
}

I do not know how these 2 fit  :  the download apiAPI if there is one andand the click event handler if you plan to do additional logic when downloading.

Hello I want to be able to download a given file when pressing a button.The file will be provided via an api call.For now i will have it in my local storage. So my folder is something like :

rootFolder
-js file
-html file
-download file (`sample.csv`)

How can I create a download link? I have tried so far with : <a download="sample.csv"></a> I have also tried using an onclick event:

<a download="sample.csv" onclick="download()"></a>

function download|(){
   .....code that calls the `api`
}

I do not know how these 2 fit  :the download api if there is one and the click event handler if you plan to do additional logic when downloading.

I want to be able to download a given file when pressing a button.The file will be provided via an API call.For now, I will have it in my local storage. So my folder is something like :

rootFolder
-JS file
-HTML file
-download file (`sample.csv`)

How can I create a download link? I have tried so far with : <a download="sample.csv"></a> I have also tried using an onclick event:

<a download="sample.csv" onclick="download()"></a>

function download|(){
   .....code that calls the `api`
}

I do not know how these 2 fit:  the download API if there is one and the click event handler if you plan to do additional logic when downloading.

improved formatting.
Source Link
RBT
  • 25.4k
  • 21
  • 170
  • 253

Hello iI want to be able to download a given file when pressing a button.The file will be provided via an api call.For now i will have it in my local storage. So my folder is something like :

rootFolder
-js file
-html file
-download file (`sample.csv`)

How can iI create a download link? I have tried so far with : <a download="sample.csv"></a> I have also tried using an onclick event:

<a download="sample.csv" onclick="download()"></a>

function download|(){
   .....code that calls the `api`
}

I do not know how these 2 fit :the download api if there is one and the click event handler if you plan to do additional logic when downloading.

Hello i want to be able to download a given file when pressing a button.The file will be provided via an api call.For now i will have it in my local storage. So my folder is something like :

rootFolder
-js file
-html file
-download file (`sample.csv`)

How can i create a download link? I have tried so far with : <a download="sample.csv"></a> I have also tried using an onclick event:

<a download="sample.csv" onclick="download()"></a>

function download|(){
   .....code that calls the `api`
}

I do not know how these 2 fit :the download api if there is one and the click event handler if you plan to do additional logic when downloading.

Hello I want to be able to download a given file when pressing a button.The file will be provided via an api call.For now i will have it in my local storage. So my folder is something like :

rootFolder
-js file
-html file
-download file (`sample.csv`)

How can I create a download link? I have tried so far with : <a download="sample.csv"></a> I have also tried using an onclick event:

<a download="sample.csv" onclick="download()"></a>

function download|(){
   .....code that calls the `api`
}

I do not know how these 2 fit :the download api if there is one and the click event handler if you plan to do additional logic when downloading.

Source Link
Bercovici Adrian
  • 9.2k
  • 18
  • 81
  • 171

How to download file with javascript?

Hello i want to be able to download a given file when pressing a button.The file will be provided via an api call.For now i will have it in my local storage. So my folder is something like :

rootFolder
-js file
-html file
-download file (`sample.csv`)

How can i create a download link? I have tried so far with : <a download="sample.csv"></a> I have also tried using an onclick event:

<a download="sample.csv" onclick="download()"></a>

function download|(){
   .....code that calls the `api`
}

I do not know how these 2 fit :the download api if there is one and the click event handler if you plan to do additional logic when downloading.