title: Close browser window after opening Custom Protocol
body: <p>I have created an ASP.Net application page to handle opening <a href="http://interwoven.com.cn/products/worksite/deskmail_site.html" rel="nofollow noreferrer" title="FileSite">FileSite</a> links. There is a custom protocol which is handling the links correctly, i.e it opens the files, however it leaves me with an empty browser page as the file is launched.</p>
  
  <p>I have 3 scenarios I am working with</p>
  
  <ol>
  <li>Links directly to the handling page will launch the file and close the browser</li>
  <li>Links from another page on the Intranet will launch handling page, open the file and return to the originating page</li>
  <li>Links from a dialog on the Intranet open the handling page, launch the file and then close the handling page</li>
  </ol>
  
  <p>The code I have is the following (Codebehind is setting the FileUrl and choosing which function to call of the two)</p>
  
  <pre><code>&lt;script type="text/javascript" language="javascript"&gt;
  
      // Files opened directly from link
      function OpenFileSiteLink() {
          window.location.href = '&lt;%= FileUrl %&gt;';
      }
  
      // Files opened from within Intranet
      function OpenFileSiteLinkReferrer(referrer, dialogOpened) {
  
          window.open('&lt;%= FileUrl %&gt;');
  
          if (dialogOpened) {
              window.open('close.html', '_self');
          } else {
              window.location.href = referrer;
          }
      }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>The code in the close.html file has only the following</p>
  
  <pre><code> &lt;script type="text/javascript"&gt; window.close();&lt;/script&gt;
  </code></pre>
  
  <p>This was taken from <a href="https://stackoverflow.com/questions/57854/how-can-i-close-a-browser-window-without-receiving-the-do-you-want-to-close-thi">How can I close a browser window without receiving the &quot;Do you want to close this window&quot; prompt?</a></p>
  
  <p>Any suggestions how I can open the protocol to launch the application without the additional dialog would be appreciated</p>