Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
Send a link to a webpage and automatically download a file

so I have a webpage with a element similar to the following

<a href="docs/some_file.xlsx" download="some_file.xlsx" class="btn btn-primary">Download!</a>

Now I'd like to send a hyperlink to some clients via email so that they would access the webpage and at the same time have the file downloaded without them having to click on it. That way they get the file and I make sure that they see the webpage where there is a lot more information.

So far I thought about a right click and copy link to the button directly from the browser but that hyperlink simply downloads the file if I click on it from ab email and I want the browser to pop up and show the landing page where the button and info is. Any idea?

BTW, the webpage is fully static so no php running. Only HTML and javascript could be used to configure the webpage

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

What you could do - setup a certain parameter for example: https://example.com/?autodownload=1

then add a piece of javascript that either imediately, or after some timeout automatically downloads the file. Something like:

document.addEventListener("DOMContentLoaded", function(event) { 
    if (window.location.href.indexOf("autodownload") > -1)
      setTimeout(function(){ 
            window.open("https://example.com/docs/some_file.xlsx");
        }, 3000); //your timeout in miliseconds
    }
});

of course this solution will not work, if browser will block opening new windows. Second possibility with this approach is to replace the window.open function with click on the anchor itself.

about 4 years ago · Juan Pablo Isaza Report

0

You can trigger a file download with JavaScript by firing click() on an <a> tag with the download attribute. Something like this:

const $link = document.createElement('a');
$link.href = 'docs/some_file.xlsx';
$link.download = 'some_file.xlsx';
$link.click();

Keep in mind, however, that browsers may try to limit automatic file downloads in order to prevent sites doing dodgy things. I've seen this in particular when a site tries to download multiple files, so I think you'll be fine just downloading a single file.

Generally, the best way around this is to ensure that you only perform this action in response to user input, such as a click, but that doesn't sound like it would work for the solution you're looking for here.

about 4 years ago · Juan Pablo Isaza Report

0

How To Add Automatically Download Link in HTML

It is very easy to make a automatically download link in HTML

And i am going to showe you all how to make a automatically link in HTML (In 5 steps)

  1. Open your Code editor app where are you do codes and create one HTML document

  2. Once you create an HTML document in your Code editor app, Now add  Tag and Href Attribute in your HTML Documents

  3. After adding  Tag and Href Attribute in your HTML Documents, Now Provide the File or Folder location in your Href Attribute

  4. After adding the File or Folder location in your Href Attribute, Now Add the Download Attribute in your Tag

  5. After Adding the Download Attribute in your Tag, Now Save the HTML File and Check the download Link

For Example

<a href="images.png/cat.png" download>Download</a>

you can also check out this video

https://www.youtube.com/watch?v=1eQQCEMeRfE

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!