By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,389 Members | 2,070 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,389 IT Pros & Developers. It's quick & easy.

Close window after binary download

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.