473,491 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 8504
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
3732
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
2623
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
5236
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
3224
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
4096
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
1469
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
5077
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
1578
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:"...
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7190
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4881
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.