Close Download Window

1

How do I close a download window with jQuery on Internet Explorer ?

Example:

<?php 

    $arquivo = $_GET["arquivo"];    
    header("Location: $arquivo");

   echo "<script>
            $(window).ready(function() {
               window.close();
            });

        </script>";
?>

The link:

<script> 
     function winOpen() {
          window.open("download2.php?torrent=$row[torrent]&id=$row[id]&user=$_SESSION[logininput]"
,null, "height=70,width=470,status=yes,toolbar=no,menubar=no,location=no,resizable=no");
} 
</script>
<a href="javascript:;" onclick="winOpen()">TORRENT</a>

The above code works in Firefox , but not IE , remembering that this window is a file download popup that is a torrent that will open.

    
asked by anonymous 27.04.2014 / 23:33

2 answers

1

As far as I know, if you close popup window with js, if you have opened it with js. In case if you used the window.open function, window.close should work.

    
27.04.2014 / 23:55
0

Popup window

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<script type="text/javascript"> 
    function winOpen() 
    {
        window.open("aberto.html",null, "height=70,width=470,status=yes,toolbar=no,menubar=no,location=no,resizable=no");
    } 
</script>
<a href="javascript:;" onclick="winOpen()">Abrir</a>
</body>
</html>

Popup window that will be closed with certain time and function setTimeout

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Aberto Janela</title>
</head>
<body>
<script type="text/javascript"> 
    setTimeout(function(){
        window.close();
    }, 3000);
</script>
</body>
</html>

In your example put it like this:

<script type="text/javascript">
$(document).ready(function() {
  setTimeout(function(){
            window.close();
        }, 3000);
});
</script>

Changing to this code will close in 3 seconds after opening

Funcionou nos navegadores: IE, Firefox e Google Chrome
    
28.04.2014 / 01:38