We use a hidden iframe to initiate the download without reloading the
page. This is probably something that would be worth building into
Cappuccino, though I'm not sure where.
Here's the function we use in 280 Slides. It's supposed to be able to
handle multiple downloads (as long as the download begins within 2
seconds)
var DownloadIFrame = null,
DownloadSlotNext = null;
var downloadURL = function downloadURL(url)
{
if (DownloadIFrame == null)
{
DownloadIFrame = document.createElement("iframe");
DownloadIFrame.style.position = "absolute";
DownloadIFrame.style.top = "-100px";
DownloadIFrame.style.left = "-100px";
DownloadIFrame.style.height = "0px";
DownloadIFrame.style.width = "0px";
document.body.appendChild(DownloadIFrame);
}
var now = new Date().getTime(),
downloadSlot = (DownloadSlotNext && DownloadSlotNext >
now) ? DownloadSlotNext : now;
DownloadSlotNext = downloadSlot + 2000;
window.setTimeout(function() {
if (DownloadIFrame != null)
DownloadIFrame.src = url;
}, downloadSlot - now);