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

304
Views
Detect file download event of a file link in JavaScript

Basically, I have different files stored on a server and I want to show/view the files in an iframe using their links. If a file is an image, it works as intended showing the image, but other files like .doc or .pptx gets downloaded instead. How can I detect that download event so that I can prevent it and show a 'No preview available' warning?

Here's the part where I display the files. I don't really know where to go from here.

<div id="file-container">
   <iframe src="/file/from/server.xyz" frameborder="0"></iframe>
</div>
about 4 years ago · Juan Pablo Isaza
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!