Auto-closing a popup with a file to download

后端 未结 4 1722
误落风尘
误落风尘 2021-02-06 16:16

I have a file, named download.php, which contains a file to be downloaded, so it has the following headers (declared with PHP):

header(\"Content-Typ         


        
4条回答
  •  忘了有多久
    2021-02-06 16:24

    You may use the following snippet to close the current window (credits to this SO answer) :

    window.open(window.location, '_self').close();
    

    To run this after a given interval, simply use setTimeout

    setTimeout(function() { window.open(window.location, '_self').close(); }, 3000);
    

提交回复
热议问题