• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

How to close the popup window automatically after download completes

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi everyone,
i this sample i am having two links "click for pdf" and "click for doc". First if the user clicks on any of the link it should validate if the file is .doc or .pdf if it's .pdf file then a popup window should come and the .pdf file should open in it and if the user clicks on "click for doc" a popup window should come up and it should give you the option to download the .doc file and the popup window should automatically close. i am able to validate the file extension and the link "click for pdf" is working as it is suppose to. But if the user clicks on "click for doc" a popup window pops up i am not able to close that window after the download completes. Please "HELP ME!"

This is my Code Snippet:

<html>
<head>
<title>
</title>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"></script>

<script type="text/javascript">
var windowSizeArray = [ "width=200,height=200",
"width=300,height=400,scrollbars=yes" ];

$(document).ready(function () {
$("a[href*=.pdf]").click(function () {
window.open(this.href, "ventana1", "width=520,height=300,scrollbars=yes");
return false;
});

});
</script>

<script type="text/javascript">


var windowSizeArray = ["width=200,height=200",
"width=300,height=400,scrollbars=yes"];

$(document).ready(function () {
$("a[href*=.doc]").click(function () {
//
var ab = window.open(this.href, "ventana1", "width=520,height=300,scrollbars=yes");
//ab.close();
//ab.setTimeout("window.close();", 5000);
//ab.setTimeout("alert('I am displayed after 3 seconds!')", 200);
ab.setTimeout("self.close()", 3000);
return false;
});

});

</script>

</head>

<body>

<a href="http://java.sun.com/docs/books/jls/download/langspec-3.0.pdf" >click for pdf</a><br /><br />
<a href="http://www.google.co.in/url?sa=t&rct=j&q=.doc&source=web&cd=13&ved=0CD8QFjACOAo&url=http%3A%2F%2Fgrants.nih.gov%2Fgrants%2Ffunding%2F416%2Fphs416-5.doc&ei=s1VHT5tPhfCtB7a_zcgP&usg=AFQjCNEJfrh5P2gvHLSh7M03SYtBI91uNg" >click for doc</a>
</body>
</html>

Thanks in advance
Sanjay Dakolia
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no way to detect download status.

Eric
 
sanjay dakolia
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eric Pascarello wrote:There is no way to detect download status.

Eric


i don't want the popup window to close after the download is completed i want it to close once the download has started.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no event to tell you when it has started either.
 
sanjay dakolia
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey guys i got the solution

$(document).ready(function () {
$("a[href*=.doc]").click(function () {
//
var ab = window.open(this.href, "ventana1", "width=520,height=300,scrollbars=yes");
setTimeout(function(){
ab.close();
},3000);
//ab.setTimeout("self.close()", 3000);
return false;
});
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Calling that a "solution" is a bit of a stretch.
 
It looks like it's time for me to write you a reality check! Or maybe a tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic