> My understanding is that the Content-Disposition tells the browser to save
> the file, and suggest the filename "report{date}.pdf. This isn't happening
> though. Nothing happens. Any ideas why the browser is not prompting to Save
> As?
>
>
The standard trick is to use a hidden IFRAME - that lets you download
without replacing your current page. My code looks like:
url = 'full-size/' + encodeURIComponent(album.title).replace(/'/g, '%27') +
'/' + encodeURIComponent(metadata.fileName).replace(/'/g, '%27');
if (/webOS\/\d+\.\d+|hpwOS\/\d+\.\d+\.\d+|Mobile\S* Safari\/\S+|Android
\d+\.\d+/.test(window.navigator.userAgent)) {
window.open(url, '_blank');
} else {
iframe = document.getElementById(hiddenIFrameID);
if (iframe === null) {
iframe = document.createElement('iframe');
iframe.id = hiddenIFrameID;
iframe.style.display = 'none';
document.body.appendChild(iframe);
}
iframe.src = url;
}
The if-statement handles several mobile browsers that don't work with the
hidden IFRAME trick. There, the code just opens the file in a new window.
If it's a picture, you can long-tap or some such to save it. I've never
tried to download a PDF, so iOS may still not play nice.
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.