Solved

Download file and close window

Posted on 2001-09-13
8
514 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 
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

MongoDB Through a MySQL Lens

This article looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

631 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