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

148
Views
innerHTML funcionando, pero eliminando HTML y etiquetas de encabezado

Estoy creando una especie de generador de correo electrónico. Una de las principales cosas que se necesitan es la función "Descargar HTML" para descargar el correo electrónico completo. Para hacerlo, utilicé innerHTML y funciona casi a la perfección, pero cuando se guarda el nuevo archivo, elimina las etiquetas y, que son necesarias para una representación adecuada.

¿Alguien sabe cómo puedo incluir estas dos etiquetas en mi descarga? ¡Gracias por adelantado!

Aquí está mi código:

 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.js" integrity="sha512-n/4gHW3atM3QqRcbCn6ewmpxcLAHGaDjpEBu4xZd47N0W2oQ+6q7oc3PXstrJYXcbNU1OHdQ1T7pAP+gi5Yu8g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <a style="background-color: #c028b9; color: white; text-decoration: none; padding: 2% 3%; border-radius: 999px" href="#" id="downloadLink">Download email html</a> <script> function downloadInnerHtml(filename, elId, mimeType) { var elHtml = document.getElementById(elId).innerHTML; var link = document.createElement('a'); mimeType = mimeType || 'text/html'; link.setAttribute('download', filename); link.setAttribute('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(elHtml)); link.click(); } var fileName = 'emailName_renameMe.html'; $('#downloadLink').click(function(){ downloadInnerHtml(fileName, 'emailPreview','text/html'); }); </script> <div id="emailPreviewWrapper" class="emailPreviewWrapper" style="width: 50%; float: right; position:relative;"> <div id="emailPreview"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.ooorg/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http:www.w3.org/1999/xhtml"> <head> <style></style> </head> <table> <tr> <td> Email Content</td> </tr> </table> </html> </div>

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!