Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to close the popup window automatically after download completes

    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 u 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%2Ff unding%2F416%2Fphs416-5.doc&ei=s1VHT5tPhfCtB7a_zcgP&usg=AFQjCNEJfrh5P2gvHLSh7M03SYtBI91uNg" >click for doc</a>
    </body>
    </html>

    Thanks in advance
    Sanjay Dakolia

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,729
    Thanks
    202
    Thanked 2,507 Times in 2,485 Posts
    See:- *** WARNING: Questions posted here will be deleted! ***.

    You will not get any reply in this forum which is intended to be used only to
    post a completed (working) script for showcasing/benefit of others.

    Before you post again please read the forum rules and posting guidelines, and the use of code tags.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    Instead of using an <a> to open the doc, you might have to use window.open() which you then have control over regarding closing.

    Also, this is your first post so don't worry about anyone whinging about not using code tags. It took me a few posts before I found how to use the code tags.

    To make posted code easier to read, you can wrap it in code tags by first highlighting the code and then click the # icon in the editors toolbar.
    Last edited by webdev1958; 03-06-2012 at 09:26 AM.

  • #4
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks buddy

  • #5
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    Quote Originally Posted by sanjay.dakolia View Post
    thanks buddy
    no problem

  • #6
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by webdev1958 View Post
    no problem
    can u plz make the necessary changes and mail me the files on sanjay.dakolia@hotmail.com
    thanks in advance
    sanjay dakolia

  • #7
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    Quote Originally Posted by sanjay.dakolia View Post
    can u plz make the necessary changes and mail me the files on sanjay.dakolia@hotmail.com
    thanks in advance
    sanjay dakolia
    Sorry, but I don't take on paid work over the internet or from people I can't meet face to face. Try posting in the Projects forum if you need someone to do it for you.

  • #8
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hey guys i got the solution for this

    $(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;
    });


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •