title: What causes IE8 to block some file downloads?
body: <p>This is causing some grief among my IE8 users.</p>
  
  <p>On my site I have file downloads launched via php script (file_download.php?file=X123).
  In this page it records some data to a database, then uses headers to force the download. Everything on this page seems to works fine on all browsers.</p>
  
  <p>Its how I call this page that seems to be giving me the annoying little "To help protect your security - Internet Explorer has blocked site from downloading files to your computer".</p>
  
  <p>If I use a regular href tag <code>&lt;a href="/file_download.php?file=X123"&gt;download&lt;/a&gt;</code> it launches correctly (with no IE blocked download message).</p>
  
  <p>But when I launch using a jQuery script it gives me this warning.</p>
  
  <p>So I figured IE8 might be suspicious of javascript redirects, so I made a simple JS function on the local page, but it worked no problem.</p>
  
  <p>So it seems jQuery may be the culprit... is it because the window.location event is called from another page or script source? Does anyone know how this works?</p>
  
  <p>I will continue testing but for now, could anyone shine some light on this issue? Asking  users to tweak their IE settings is not an option.</p>
  
  <p>Thanks</p>
  
  <p>-------- jQuery Code --------------</p>
  
  <pre><code>            jQuery("a").click(function(e){
  
              if(jQuery(this).attr("href") !== undefined){
  
                  downloadLink = jQuery(this).attr("href");
                  thingClicked = jQuery(this);
  
                  dll_io = downloadLink.indexOf("/file_download.php?file_id=");
                  dll_io2 = downloadLink.indexOf("/file_download_safe.php?file_id=");
  
  
                      if(dll_io == 0 || dll_io2 == 0){
  
                          e.preventDefault();
  
                          jQuery.getScript("/includes/get_login.php?file_id=" + downloadLink + "&amp;dll_io=" + dll_io + "&amp;dll_io2=" + dll_io2 + "&amp;last_url=" + document.URL, function(rp){
                              //get_login.php sets 'requested_dl_id' cookie
  
                              if(dll_io2 == 0){
                                  window.location = downloadLink;
                              }else{  
                                  if(rp == "allow"){
                                      window.location = downloadLink;
                                  }else{
                                      jQuery("#download_prompt").click();
                                  }
                              }//end condition: if file_download_safe -&gt; set cookie and send to page. IF file_download -&gt; set cookie and decide to prompt or not.
  
                          });
                      }//end if fd == file_download.php
              }//end only execute code if 'a' has a defined 'href' attribute
  
          });
  </code></pre>
  
  <p>----update----</p>
  
  <p>I have now educated myself enough to understand the cause of this problem - but no simple solution. The cause is IE7 &amp; 8 automatically block downloads that are launched from non-user events. So an onclick event will launch a download, but not a jQuery script. Still searching for a workaround.</p>