Solved

Download file and close window

Posted on 2001-09-13
8
498 Views
Last Modified: 2013-12-24
Hi all,

I have a link that when user click it, it will pop up a new window that executes CF code and the user will have options to download the file (the default window that says you want to open it or save it to the disk).

My problem is when I choose neither ok or cancel to that download options, the pop window won't close and it just blank.

I put this script in my pop up window.

<script>
  self.location = 'file1.exe';
  self.close();
</script>

the problem is it just close and won't show up the download window.

Is there anyway to close that popup window immediately after the download window show up ???

Thanks.
0
Comment
Question by:Formiguinha
8 Comments
 
LVL 1

Expert Comment

by:Drewbytes
ID: 6481837
Try window.close(); instead.

I have used this before in similiar situations and it does close the popup window after doing something in the main window.
0
 

Author Comment

by:Formiguinha
ID: 6481995
Hi,

I try it. Still doesn't work. I think the problem is I put the self.close() or window.close() after self.location() so it won't execute the self.location() at all but just close the window without showing any download dialog at all.

What I'm going to do is I show up the download dialog and close the html window open after I choose ok to save it to the disk or open it from current location.

Any suggestion ??
0
 
LVL 2

Accepted Solution

by:
sshhz earned 50 total points
ID: 6482371
Formiguinha,

I ve a suggestion. Assume user clicks on the page call download.cfm (a listing of files to download). Then when they click the link of the file, or you can provide an image to represent download, once they click this ... straight away call File Download window, asking "What would you like to do with this file?" Either you "open this file from its current location" or "save this file to disk" .... then you need not have to worry whether you want to close the pop up new window for it.

sshhz

0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 2

Expert Comment

by:kc5sig
ID: 6482444
You're moving the location of the window, so your "close" won't work.

What you might want to try is opening a pop-up that points to the file and then closing the caller.  See if that works.

HTH
Hatton Humphrey
0
 
LVL 5

Expert Comment

by:Yog
ID: 6482763
<script>
 self.location = 'file1.exe';
 opener.window.location.href="pagethatopenedpopup.cfm"
 window.close();
</script>

0
 
LVL 2

Expert Comment

by:sshhz
ID: 6486427
Formiguinha,

<SCRIPT>
 window.opener.close();
</SCRIPT>

it close the opener window.

sshhz
0
 
LVL 2

Expert Comment

by:sshhz
ID: 6486430
Formiguinha,

Thanks for credits. I didn't know you've chosen my comment as answers as i posted another script to close the opener window. Anyway, thanks again.

sshhz
0
 

Author Comment

by:Formiguinha
ID: 6486455
No,

I try the yog script but the idea is from you.

Thanks for your helps guys :D
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question