473,239 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,239 software developers and data experts.

Close window after binary download

I have an ASP page that is sent a file location as a parameter. It opens
this file, loads the ADODB.Stream object and does a binary write to the page
forcing the download dialog to appear. This all works fine. If the user
selects "Open" or "Cancel", the window closes, which is the desired behavior.
If they select "Save", the location dialog shows up, they save the file and
the window remains open. I've tried a number of things to get the window to
close automagically, or at least to get a "Close window" button or link to
show up, but nothing has worked. Is this possible, or will my users always
have to close the window manually?
Jul 21 '05 #1
6 8476
I don't see this behavior. The download doesn't open a new window. How do
you call the download page ?

I would suggest to use just an anchor tag wiht no target. The browser will
get the new content and as this is not an HTML content :
- the current page remains intact
- it just opens the donwload dialog without any "new window"

Patrice

--

"chon" <ch**@discussions.microsoft.com> a écrit dans le message de
news:14**********************************@microsof t.com...
I have an ASP page that is sent a file location as a parameter. It opens
this file, loads the ADODB.Stream object and does a binary write to the page forcing the download dialog to appear. This all works fine. If the user
selects "Open" or "Cancel", the window closes, which is the desired behavior. If they select "Save", the location dialog shows up, they save the file and the window remains open. I've tried a number of things to get the window to close automagically, or at least to get a "Close window" button or link to
show up, but nothing has worked. Is this possible, or will my users always have to close the window manually?

Jul 21 '05 #2
Hi, Patrice,

The new window is being launched via javascript:
window.open("Download.asp?Filelocation=<file path>","download",strFeatures).
We're doing it this way because we don't want to overwrite the current window
(which will happen if the browser recognizes the file type and displays it).
We also want to give the user the option to open it or download it rather
than letting the browser decide.

Thanks,

Chon

"Patrice" wrote:
I don't see this behavior. The download doesn't open a new window. How do
you call the download page ?

I would suggest to use just an anchor tag wiht no target. The browser will
get the new content and as this is not an HTML content :
- the current page remains intact
- it just opens the donwload dialog without any "new window"

Patrice

--

"chon" <ch**@discussions.microsoft.com> a écrit dans le message de
news:14**********************************@microsof t.com...
I have an ASP page that is sent a file location as a parameter. It opens
this file, loads the ADODB.Stream object and does a binary write to the

page
forcing the download dialog to appear. This all works fine. If the user
selects "Open" or "Cancel", the window closes, which is the desired

behavior.
If they select "Save", the location dialog shows up, they save the file

and
the window remains open. I've tried a number of things to get the window

to
close automagically, or at least to get a "Close window" button or link to
show up, but nothing has worked. Is this possible, or will my users

always
have to close the window manually?


Jul 21 '05 #3
Sorry, I thought you were really already "forcing" the download dialog.

http://support.microsoft.com/default.aspx?id=260519 allows to force the
download dialog even for know mime types.
This way you have always the same behavior and you don't have to open this
new window...

Is it applicable or do you actually WANT to have the current behavior for
know mime types ?

Patrice

--

"chon" <ch**@discussions.microsoft.com> a écrit dans le message de
news:D1**********************************@microsof t.com...
Hi, Patrice,

The new window is being launched via javascript:
window.open("Download.asp?Filelocation=<file path>","download",strFeatures). We're doing it this way because we don't want to overwrite the current window (which will happen if the browser recognizes the file type and displays it). We also want to give the user the option to open it or download it rather
than letting the browser decide.

Thanks,

Chon

"Patrice" wrote:
I don't see this behavior. The download doesn't open a new window. How do you call the download page ?

I would suggest to use just an anchor tag wiht no target. The browser will get the new content and as this is not an HTML content :
- the current page remains intact
- it just opens the donwload dialog without any "new window"

Patrice

--

"chon" <ch**@discussions.microsoft.com> a écrit dans le message de
news:14**********************************@microsof t.com...
I have an ASP page that is sent a file location as a parameter. It opens this file, loads the ADODB.Stream object and does a binary write to the
page
forcing the download dialog to appear. This all works fine. If the
user selects "Open" or "Cancel", the window closes, which is the desired

behavior.
If they select "Save", the location dialog shows up, they save the file and
the window remains open. I've tried a number of things to get the
window to
close automagically, or at least to get a "Close window" button or

link to show up, but nothing has worked. Is this possible, or will my users

always
have to close the window manually?


Jul 21 '05 #4
Hi, Patrice,

Thanks for the pointer to the article. Perhaps I'm being dense, but I don't
see how it's possible to send the content-disposition header without
submitting the page so that either some ASP code executes within the page, or
a new page is launched that will handle the Response.AddHeader. If I submit
the page to itself and execute Response.AddHeader to change
content-disposition to "attachment", the HTML content of the page will no
longer display so I might as well launch a different page, no?

The reason for opening a new window is to preserve the contents of the page
from which the download is being requested. The download.asp page that we're
currently using is forcing the download dialog by using the
Response.AddHeader and that works correctly, however, there's no way to
display an HTML button to close the page once the download is complete if the
user chooses "Save" instead of "Open" or "Cancel". At least there's no way
that I've been able to find.

Thanks,

Chon

"Patrice" wrote:
Sorry, I thought you were really already "forcing" the download dialog.

http://support.microsoft.com/default.aspx?id=260519 allows to force the
download dialog even for know mime types.
This way you have always the same behavior and you don't have to open this
new window...

Is it applicable or do you actually WANT to have the current behavior for
know mime types ?

Patrice

--

"chon" <ch**@discussions.microsoft.com> a écrit dans le message de
news:D1**********************************@microsof t.com...
Hi, Patrice,

The new window is being launched via javascript:
window.open("Download.asp?Filelocation=<file

path>","download",strFeatures).
We're doing it this way because we don't want to overwrite the current

window
(which will happen if the browser recognizes the file type and displays

it).
We also want to give the user the option to open it or download it rather
than letting the browser decide.

Thanks,

Chon

"Patrice" wrote:
I don't see this behavior. The download doesn't open a new window. How do you call the download page ?

I would suggest to use just an anchor tag wiht no target. The browser will get the new content and as this is not an HTML content :
- the current page remains intact
- it just opens the donwload dialog without any "new window"

Patrice

--

"chon" <ch**@discussions.microsoft.com> a écrit dans le message de
news:14**********************************@microsof t.com...
> I have an ASP page that is sent a file location as a parameter. It opens > this file, loads the ADODB.Stream object and does a binary write to the page
> forcing the download dialog to appear. This all works fine. If the user > selects "Open" or "Cancel", the window closes, which is the desired
behavior.
> If they select "Save", the location dialog shows up, they save the file and
> the window remains open. I've tried a number of things to get the window to
> close automagically, or at least to get a "Close window" button or link to > show up, but nothing has worked. Is this possible, or will my users
always
> have to close the window manually?


Jul 21 '05 #5
The key point is that the browser decides what to do not before but *after*
getting the new content. Based on the header, the browser sees that it
should raise a download dialog and that there is then no need to recycle the
window (at least this is what we see using IE). Its content is then left
unchanged and as a result you don't need this new window to protect the
content.

The KB article allows to always raise this dialog so that it will take
always the same decision (ie raise the dialog instead of displaying
automatically the new content).

You may want still to give this a try with the browsers you are supporting
but I'm quite confident the behavior should be the same.

If you keep the new window option, the only thing I can think of would be to
trigger the download using a frame (possibly a IFRAME or even an IMG tag) so
that you can have some script that closes the window either automatically
once the document is entirely completed or by using asking for user input as
a last resort.

Hope it helps.

Patrice

--

"chon" <ch**@discussions.microsoft.com> a écrit dans le message de
news:DD**********************************@microsof t.com...
Hi, Patrice,

Thanks for the pointer to the article. Perhaps I'm being dense, but I don't see how it's possible to send the content-disposition header without
submitting the page so that either some ASP code executes within the page, or a new page is launched that will handle the Response.AddHeader. If I submit the page to itself and execute Response.AddHeader to change
content-disposition to "attachment", the HTML content of the page will no
longer display so I might as well launch a different page, no?

The reason for opening a new window is to preserve the contents of the page from which the download is being requested. The download.asp page that we're currently using is forcing the download dialog by using the
Response.AddHeader and that works correctly, however, there's no way to
display an HTML button to close the page once the download is complete if the user chooses "Save" instead of "Open" or "Cancel". At least there's no way that I've been able to find.

Thanks,

Chon

"Patrice" wrote:
Sorry, I thought you were really already "forcing" the download dialog.

http://support.microsoft.com/default.aspx?id=260519 allows to force the
download dialog even for know mime types.
This way you have always the same behavior and you don't have to open this new window...

Is it applicable or do you actually WANT to have the current behavior for know mime types ?

Patrice

--

"chon" <ch**@discussions.microsoft.com> a écrit dans le message de
news:D1**********************************@microsof t.com...
Hi, Patrice,

The new window is being launched via javascript:
window.open("Download.asp?Filelocation=<file

path>","download",strFeatures).
We're doing it this way because we don't want to overwrite the current

window
(which will happen if the browser recognizes the file type and displays
it).
We also want to give the user the option to open it or download it
rather than letting the browser decide.

Thanks,

Chon

"Patrice" wrote:

> I don't see this behavior. The download doesn't open a new window. How do
> you call the download page ?
>
> I would suggest to use just an anchor tag wiht no target. The
browser will
> get the new content and as this is not an HTML content :
> - the current page remains intact
> - it just opens the donwload dialog without any "new window"
>
> Patrice
>
> --
>
> "chon" <ch**@discussions.microsoft.com> a écrit dans le message de
> news:14**********************************@microsof t.com...
> > I have an ASP page that is sent a file location as a parameter.
It opens
> > this file, loads the ADODB.Stream object and does a binary write
to the
> page
> > forcing the download dialog to appear. This all works fine. If
the user
> > selects "Open" or "Cancel", the window closes, which is the
desired > behavior.
> > If they select "Save", the location dialog shows up, they save the file
> and
> > the window remains open. I've tried a number of things to get the

window
> to
> > close automagically, or at least to get a "Close window" button or

link to
> > show up, but nothing has worked. Is this possible, or will my

users > always
> > have to close the window manually?
>
>
>


Jul 21 '05 #6
Hi, Patrice,

Okay, I'm going to have to play with that a while and see if it will work
the way we're constructing our pages. Thanks very much for your time.

Chon

"Patrice" wrote:
The key point is that the browser decides what to do not before but *after*
getting the new content. Based on the header, the browser sees that it
should raise a download dialog and that there is then no need to recycle the
window (at least this is what we see using IE). Its content is then left
unchanged and as a result you don't need this new window to protect the
content.

The KB article allows to always raise this dialog so that it will take
always the same decision (ie raise the dialog instead of displaying
automatically the new content).

You may want still to give this a try with the browsers you are supporting
but I'm quite confident the behavior should be the same.

If you keep the new window option, the only thing I can think of would be to
trigger the download using a frame (possibly a IFRAME or even an IMG tag) so
that you can have some script that closes the window either automatically
once the document is entirely completed or by using asking for user input as
a last resort.

Hope it helps.

Patrice

--

"chon" <ch**@discussions.microsoft.com> a écrit dans le message de
news:DD**********************************@microsof t.com...
Hi, Patrice,

Thanks for the pointer to the article. Perhaps I'm being dense, but I

don't
see how it's possible to send the content-disposition header without
submitting the page so that either some ASP code executes within the page,

or
a new page is launched that will handle the Response.AddHeader. If I

submit
the page to itself and execute Response.AddHeader to change
content-disposition to "attachment", the HTML content of the page will no
longer display so I might as well launch a different page, no?

The reason for opening a new window is to preserve the contents of the

page
from which the download is being requested. The download.asp page that

we're
currently using is forcing the download dialog by using the
Response.AddHeader and that works correctly, however, there's no way to
display an HTML button to close the page once the download is complete if

the
user chooses "Save" instead of "Open" or "Cancel". At least there's no

way
that I've been able to find.

Thanks,

Chon

"Patrice" wrote:
Sorry, I thought you were really already "forcing" the download dialog.

http://support.microsoft.com/default.aspx?id=260519 allows to force the
download dialog even for know mime types.
This way you have always the same behavior and you don't have to open this new window...

Is it applicable or do you actually WANT to have the current behavior for know mime types ?

Patrice

--

"chon" <ch**@discussions.microsoft.com> a écrit dans le message de
news:D1**********************************@microsof t.com...
> Hi, Patrice,
>
> The new window is being launched via javascript:
> window.open("Download.asp?Filelocation=<file
path>","download",strFeatures).
> We're doing it this way because we don't want to overwrite the current
window
> (which will happen if the browser recognizes the file type and displays it).
> We also want to give the user the option to open it or download it rather > than letting the browser decide.
>
> Thanks,
>
> Chon
>
> "Patrice" wrote:
>
> > I don't see this behavior. The download doesn't open a new window. How do
> > you call the download page ?
> >
> > I would suggest to use just an anchor tag wiht no target. The browser will
> > get the new content and as this is not an HTML content :
> > - the current page remains intact
> > - it just opens the donwload dialog without any "new window"
> >
> > Patrice
> >
> > --
> >
> > "chon" <ch**@discussions.microsoft.com> a écrit dans le message de
> > news:14**********************************@microsof t.com...
> > > I have an ASP page that is sent a file location as a parameter. It opens
> > > this file, loads the ADODB.Stream object and does a binary write to the
> > page
> > > forcing the download dialog to appear. This all works fine. If the user
> > > selects "Open" or "Cancel", the window closes, which is the desired > > behavior.
> > > If they select "Save", the location dialog shows up, they save the file
> > and
> > > the window remains open. I've tried a number of things to get the
window
> > to
> > > close automagically, or at least to get a "Close window" button or
link to
> > > show up, but nothing has worked. Is this possible, or will my users > > always
> > > have to close the window manually?
> >
> >
> >


Jul 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Kevin Knorpp | last post by:
Hello. I need to be able to extract the data from the attached file (or any file in the same format) so that I can work with the data in PHP. I'm fairly comfortable with using PHP with...
4
by: geradeaus | last post by:
Hi, I use a php class to create pdf files (http://www.ros.co.nz/pdf/) ... but when I download the created pdf, the browser window closes, and Acrobat opens. How do I prevent the closing of...
1
by: Navin | last post by:
i open the file download.asp from another main.asp page using window.open what the problem is when i clikc on the hyperlink it prompts me the ie save dialog box taht fine. but when the script...
9
by: Graham | last post by:
What I currently have is a page that opens another browser at 800x600, once that is loaded I would like to close the orginal page down while keeping the page that it has just opened open (To make...
3
by: Volodymyr Lozovoy | last post by:
Help novice I open new window using window.open(), then user click button in this window and i create file and return it user using Response.Redirect(fileName). How i can close the window after...
1
by: Onin Tayson | last post by:
Hi All, I have an ASP page that is sent a file location as a parameter. It opens this file, loads the ADODB.Stream object and does a binary write to the page forcing the download dialog to...
2
by: mamin | last post by:
Hi, I need to send a file to a client and then close current window. My code looks as follows: Response.ContentType="application/bmp"; Response.AppendHeader("","attachment; filename=\"" +...
1
by: Don M | last post by:
I have some code on one of my pages that opens a new window and a Flash SWF game. This is not all of it. Part of it is embedded. <object classid="clsid:"...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.