Bug 263608 - TXT and XML Files open in tab on iOS Safari instead of downloading
Summary: TXT and XML Files open in tab on iOS Safari instead of downloading
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 16
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Keywords: InRadar
Depends on:
Reported: 2023-10-24 13:12 PDT by Celeste Glavin
Modified: 2024-01-11 06:29 PST (History)
4 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Celeste Glavin 2023-10-24 13:12:24 PDT
Steps to reproduce:
- define an anchor element with the download attribute and a url to download either a TXT or XMl file
- fire the click event on iOS Safari (Current version is 16.6.1)

- Download starts

- file is opened in the current tab

Example of code:
const downloadExportUrl = (url) => {
  const a = document.createElement('a');
  a.href = url;
  a.download = '';
Comment 1 Radar WebKit Bug Importer 2023-10-24 14:10:54 PDT
Comment 2 pollx 2024-01-11 06:29:40 PST
Same issue when trying to download a pdf file in the form of Blob:

    const pdfBlob = await pdfBinaryRes.blob()

    const blobUrl = window.URL.createObjectURL(pdfBlob)

    const link = document.createElement('a')
    link.href = blobUrl
    link.download = filename