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

268
Vistas
Export iframe content as an HTML file

I'm trying to achieve pretty basic function but still didn't succeed. How it should work - a user clicks a button and the iframe content is being exported as a html file. This is the code i have:

HTML:

<input type="button" value="Export" onclick="exportLog();">
<iframe id="log" src="https://colorfill.pl/email_signature.html">
</iframe>

JS:

function exportLog(){
    var elHtml = document.getElementById('log').innerText;
    var link = document.createElement('a');
    var mimeType = 'text/html';

    link.setAttribute('download', 'logFile');
    link.setAttribute('href', 'data:' + mimeType  +  ';charset=utf-8,' + encodeURIComponent(elHtml));
    link.click();
}

Fiddle: https://jsfiddle.net/hbvxkmnf/

I've also tried to change innerText into innerHTML, so far without success..

At the moment script downloads the file yet its totally empty.

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