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

111
Vistas
Download a Data URL using Safari

we are developping an app where we need to download a PDF file generated on the client side. We are using a string to feed the contents of the file into a data URL, like so:

const pdfContent = 'xxxxx';
    const element = document.createElement('a');
    element.setAttribute('href', `data:application/pdf;charset=utf-8,${encodeURIComponent(pdfContent)}`);
    element.setAttribute('download', 'mypdf.pdf');
    element.style.display = 'none';

    document.body.appendChild(element);

    element.click();

    document.body.removeChild(element);

This works very well using Microsoft Edge, but it bugs out in Safari saying 'not allowed to navigate top frame to data URL'.

The host application does not allow for window.open() or any such tricks, I tried using an iframe but it wouldn't work, amybe I did it wrong. I also tried other libraries like file-saver, save-file, all available on npm with the same result, cannot navigate top frame to data url.

Any hints? Thanks.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I ended up using a blob stream, which partially worked, because I'm still unable to download because it is running on a sandboxed environment (Office add-in). I guess we'll have to resort to opening a browser window and downloading a file there, unless someone has a better alternative for Office add-ins.

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