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

188
Views
la página html descargada no se abre en Chrome o Edge pero en IE y da un error de noscript - aplicación vue

En mi aplicación, estoy tratando de descargar html de la página actual que tiene el mismo nombre de dominio. He escrito algún método para descargar el html y se está descargando.

Pero he intentado abrirlo tanto en Chrome como en Edge y no se abre. Pero, en IE, se abre y muestra el texto de la etiqueta noscript ( lo sentimos, pero la aplicación no funciona correctamente sin JavaScript habilitado. Habilítelo para continuar ).

Estoy ingresando la URL del sitio de intranet y haciendo clic en el botón de descarga. Aquí está mi método a continuación.

 downloadHtml() { let url = this.urlInput; // input text v-model value fetch(url) .then((res) => res.text()) .then((html) => this.downloadAsFile("report.html", html)); // by this name it is downloading }, downloadAsFile(name, text) { const link = this.createDownloadableLink(name, text); const clickEvent = new MouseEvent("click"); link.dispatchEvent(clickEvent); }, createDownloadableLink(fileName, content) { let link = document.createElement("a"); link.href = 'data:attachment/text,' + encodeURIComponent(document.documentElement.outerHTML); link.target = '_blank'; link.download = fileName; return link; },

** Los problemas son:

 1. The app root signifies the public/index.html and that downloaded html is this one not the current page's html. 2. Chrome or Edge is not opening that html page even i checked browser is javascript enabled.

Entonces, ¿qué tengo que cambiar para descargar la página actual html?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El problema es que un archivo HTML no es un tipo de archivo de application/octet-stream . El tipo mimo de una página HTML es text/html

No estoy seguro de la forma en que intentas crear tu enlace de descarga. No tengo tiempo para probarlo, pero existe la forma en que lo hago generalmente usando la API createObjectURL :

 async function fetchHTML(url) { let content = await fetch(url).then(resp => resp.text()); let file = new Blob([content],{type:'text/html'}); let href = window.URL.createObjectURL(file); let a = document.createElement('a'); a.href = href; a.setAttribute('download', 'report.html'); document.body.appendChild(a); a.dispatchEvent(new MouseEvent('click')); }

Otro problema es que no agrega su enlace al DOM en el código que proporcionó. Por lo tanto, el DOM no puede activar el evento del mouse y, por lo tanto, iniciar la descarga (algunos navegadores lo necesitan).

Con un buen tipo de mime, el archivo en un formato adecuado y un enlace al dom, debería estar bien.

about 4 years ago · Juan Pablo Isaza Report
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!