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

277
Vistas
text/html blob that is source of iframe that has html and JS code in it, creates mimetype error

I am working on creating an iframe that will have both html and JS code in it. The code going into the blob will be something like:

'''

    <script src="{%  static 'js/bootstrap.min.js' %}" > </script> 
    <script src="https://<domain>/controller/api_browser_retrieve_script/"></script>

    <html>
    <body>
           stuff in the html...

'''

The second script src that is pointed to 'https://../api_browser_retrieve_script/' then pulls in a file of JS code from an application - and I want this script to then be available in the iframe for use in the html, as inline JS is getting dumped by my CSP policies.

This template of code from above is then put into a variable called iframecode and made into a blob called blobContent:

const blobContent = new Blob([iframecode], {type: "text/html"});
var iFrameM = document.createElement("iframe");
iFrameM.src = URL.createObjectURL(blobContent);
window.frames[0].document.body.appendChild(iFrameM);

However, when iFrameM is appended to the main page, the blob will start to load in the iframe, and then the browser will see the script tags and then fail to load the rest due to a Mimetype error. I can set the mimetype to 'application/javascript', but then the html no longer works. Is there a way to get the blob to load into the iframe and have the iframe still load the JS code and run properly?

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