SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    ********* Celica Lover Coomer's Avatar
    Join Date
    Apr 2002
    Location
    Not worth the drive
    Posts
    474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Closing a opened window after file download?

    Hello,
    On a new site I'm working on for the company here at work, I'm opening a new 100x100 window with a url to my php script which saves the pdf file to the visitor's hard drive rather than viewing it in their browser. Once the window is opened, a save file dialog box pops up and they can save the pdf file to their hard drive. As soon as they close the save file dialog by saving the file or cancelling, I want the small window to close. Can you guys help me out with this?

    I can't use any javascript code in the url that's opened in the small window because I use the php header() function and it would simply save that code with the pdf and the pdf and the code wouldn't work. So it looks like I'll have to use some code on the page that actually opens the window. Here's the existing javascript code on that page:

    Code:
    <script language="javascript">
    <!--
    my_window = window.open("pdfdownload.php?file=<?php echo $HTTP_POST_VARS['file_to_add']?>", "my_window", "width=100 height=100");
    window.location.href = "index.php?action=product_detail&itu=<?php echo $HTTP_POST_VARS['bid']?>";
    //-->
    </script>
    The file is being opened in a new window.
    Any help would be greatly appreciated! Thanks!
    + Celica =
    6G Celicas :: My '94-99 Toyota Celica resource

  2. #2
    ********* Celica Lover Coomer's Avatar
    Join Date
    Apr 2002
    Location
    Not worth the drive
    Posts
    474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think that if I could figure out a way to test to see if the "File Download" dialog with the "open, save, cancel, and more info" is open or not, then I could use setInterval() to check for this until it's closed. Then once it's closed I could simply close the window. Does anyone know how to test to see if the "File Download"(Not the dialog when the file is actually downloading, the dialog boxes before it) is closed or not. It would be great if someone knows how.

    Thanks!
    + Celica =
    6G Celicas :: My '94-99 Toyota Celica resource

  3. #3
    ********* Celica Lover Coomer's Avatar
    Join Date
    Apr 2002
    Location
    Not worth the drive
    Posts
    474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In case anyone's wondering, I finally got it working by making a frameset with a 1 pixel high top frame which has the php script to download the file and in the lower frame it says something like "Your file should start downloading momentarily..." and it has a direct link to the .pdf file in case the php script doesn't work with their browser and a link to how to open .pdf files and a link to close the window. I simply passed the filename to download through the frames via the url.
    + Celica =
    6G Celicas :: My '94-99 Toyota Celica resource


Bookmarks

Posting Permissions

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