title: How to download a PDF to a new tab/window without popup blocker?
body: <p>I have the following service call to download files from the server. I currently have it so that PDFs will open up in a new tab/window, and any other document types will be downloaded.</p>
  
  <p>The problem I'm having right now is that the PDF is being prevented by a pop up blocker. Is there any way around this?</p>
  
  <pre><code>  return formService.getForm(params)
          .$promise
          .then(response =&gt; {
              var blob = new Blob([response.data], {
                  type: response.responseType
              });
              var fileUrl = (window.URL || window.webkitURL).createObjectURL(blob);
              if (response.responseType === 'application/pdf') {
                  window.open(fileUrl);
              } else {
                  var a = document.createElement("a");
                  document.body.appendChild(a);
                  a.style = "display: none"
                  a.href = fileUrl;
                  a.download = formName;
                  a.target = "_blank";
                  a.click();
                  window.URL.revokeObjectURL(fileUrl);
              }
          })
          .catch(error =&gt; {
              console.error(`Error downloading form '${formName}' `, error);
          });
  </code></pre>