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

176
Views
HTML getting json content from iframe with src="somejsonfile.json"

i'm trying to read "local" files inside my directory with vanilla javascript inside a html. Since AJAX does not work because of CORS policy - can't read local files from a browser, I "outsmart" them using iframe which supplemented with json files that I want to read.

The problem is - I managed to get the iframe but don't know how to extract the "data" from this iframe.

chrome console

Javascript:

fileframe = document.getElementById("jsonfile");
fileframe.setAttribute("src", "test.json");
console.log(fileframe);

Chrome console output

<iframe id="jsonfile" src="test.json" style="display:none">
#document
<html>
<head>
<meta name="color-scheme" content="light dark">
 </head>
  <body>
   <pre style="word-wrap: break-word; white-space: pre-wrap;">{
"content": "thisisacontent"
   }</pre>
  </body>
 </html>
</iframe>

The data i want to get is the {"content" : "thisisacontent"} a newbie programmer here, any help will be appreciated! thanks!!

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!