Estoy tratando de lograr una función bastante básica, pero aún no tuve éxito. Cómo debería funcionar: un usuario hace clic en un botón y el contenido del iframe se exporta como un archivo html. Este es el código que tengo:
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(); }Violín: https://jsfiddle.net/hbvxkmnf/
También he intentado cambiar innerText a innerHTML, hasta ahora sin éxito.
En este momento, el script descarga el archivo pero está totalmente vacío.