Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

178
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda