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

368
Views
directory of files in an iFrame: get url of file clicked

In an iFrame (same origin), I'm displaying a list of file-links, like this:

<iframe src="my_public_folder_of_files/"></iframe>

Then, in my javascript, I'm trying to listen for the click event on those links, so I can get the href/url of the chosen file, like this

window.frames[0].document.addEventListener('click', e => {
  e.preventDefault();
  console.log(e.target.href);
})

But I'm not getting any logging at all.

If I inspect the page, I can see the <a href="file_url"> elements there, but I can't seem to access them programatically.

How can I get the url of a link clicked within a iFrame that's displaying a same-origin directory?

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!