Solved

Download file and close window

Posted on 2001-09-13
8
493 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hosting a website using port 443 SSL CA using Wampserver 2 How to: 6 54
Forbidden errors 5 144
Problem to go to page 12 93
web & database SERVERS -- PHYSICAL & VM ? 5 57
A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
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…

809 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