Close Download Dialog Box

Asked

Viewed 1,655 times

1

How do I close a download window with jQuery in the 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 code above works on Firefox, but not in the IE, remembering that this window is a file download popup that is a torrent that will open.

  • 1

    If you are forcing the download of a torrent, why do you need a popup?

  • is a system of the same style as superdownloads, opens the popup with the torrent download when you click on the link...

2 answers

1

From what I know only closes popup window with js, in case you have opened it with js. In the case if you used window.open, the window should work.close.

0

Window calling the popup

<!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 fixed 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 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 opened

Funcionou nos navegadores: IE, Firefox e Google Chrome
  • Dude, it’s not working, what’s the problem ? in the code you posted you didn’t use the header Location in php, will that be it ? when I shoot the header works

  • guy your code is wrong, the header in case there ta redirecting to the file contents, then remove if without it ta working and check your system. The code implemented by me ta working are two html take the two and test if you will understand!!! ok? if you have any question ask

Browser other questions tagged

You are not signed in. Login or sign up in order to post.