Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>So this is propably overkill but works in IE9, FF7, and Chrome 16:</p> <p>Inspired by <a href="https://stackoverflow.com/a/4168965/585552">this SO post</a></p> <p>jQuery Plugins:</p> <ul> <li><a href="https://github.com/douglascrockford/JSON-js" rel="nofollow noreferrer">json2.js</a></li> <li><a href="https://github.com/carhartl/jquery-cookie" rel="nofollow noreferrer">$.cookie()</a></li> <li><a href="http://benalman.com/projects/jquery-bbq-plugin/" rel="nofollow noreferrer">$.bbq()</a></li> </ul> <p>C# in handler:</p> <pre><code>public void ProcessRequest (HttpContext context) { ... if (!string.IsNullOrEmpty(context.Request.QueryString["downloadid"])) Response.Cookies[context.Request.QueryString["downloadid"]].Value = "complete"; } </code></pre> <p>Javascript/jQuery:</p> <pre><code>function downloadFile(url, downloadid) { //set a cookie with a unique download id $.cookie(downloadid, 'pending', { path: '/' }); //create a new url var newurl = $.param.querystring(url, { downloadid: downloadid }); //append an iframe with new url $("body").append("&lt;iframe style='height:0;width:0;' data-downloadid='" + downloadid + "' src='" + newurl + "'&gt;&lt;/iframe&gt;"); } function downloadComplete(downloadid) { //check if download is pending return $.cookie(downloadid) == "complete"; } function downloadManager(arrDownloads) { //loop through download items backwards var allComplete = false; for (var i = arrDownloads.length; i &gt; 0; i--) { if (downloadComplete(arrDownloads[i - 1].downloadid)) { //download the next one if it exists if (i == arrDownloads.length) { allComplete = true; } else { downloadFile(arrDownloads[i].url, arrDownloads[i].downloadid); } //stop checking for completed downloads break; } } if (allComplete) { //remove cookies for (var i = arrDownloads.length; i &gt; 0; i--) { $.cookie(arrDownloads[i - 1].downloadid, null, { path: '/' }); } //remove iframes $("iframe[data-downloadid]").remove(); } else { setTimeout("downloadManager(" + JSON.stringify(arrDownloads) + ");", 500); } } function downloadFiles(arrurls) { var arrDownloads = []; for (var i = 0; i &lt; arrurls.length; i++) { var item = new Object(); item.url = arrurls[i]; item.downloadid = newGuid(); arrDownloads.push(item); } //start the first download downloadFile(arrDownloads[0].url, arrDownloads[0].downloadid); //initiate the manager downloadManager(arrDownloads); } $(function () { var arrurls = []; arrurls.push("Document.ashx?clientid=123&amp;documentid=10"); arrurls.push("Document.ashx?clientid=123&amp;documentid=11"); arrurls.push("Document.ashx?clientid=123&amp;documentid=12"); arrurls.push("Document.ashx?clientid=123&amp;documentid=13"); arrurls.push("Document.ashx?clientid=123&amp;documentid=14"); downloadFiles(arrurls); }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload