473,394 Members | 1,739 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,394 software developers and data experts.

Javascript breaks after client downloads file to disk

Hey there folks,

I have a link on a page which I would like to point to string that's
downloaded as a file -- a *.tab file to be exact. The link points to a file
(download.aspx) which contains no html but uses response.write to send the
data to the client who then downloads it. Problem is, unless I get the
target attribute of the link to _blank, then any javascript I have sitting
on the page gives me an "access is denied" error, but only AFTER a file is
downloaded. I can't just point the link to an existing file since the
contents to be downloaded are generated dynamically.

Below if the code from the load event of download.aspx:

'no html on this page, just that top yellow <@ page ...> line.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim S As String
'
' Bunch of code here to build string S
'
Response.Clear()
Response.ContentType = "text/tab-separated-values"
Response.AppendHeader("Content-Disposition", "attachment;filename=" &
"myfile.tab")
Response.Write(S)
Response.Close()
End Sub

As I said, if I use the tag <A HREF="download.aspx"> then the file
downloads. But, any subsequent javascript I try to execute on the same
page, gives me Access is Denied (I have a drop down list which calls a
function on the onChange event).

If I use the tag <A HREF="download.aspx" target="_blank"> then the file
downloads and I'm ok, except for a new window that's now opened.

I tried doing it all using javascript and a child window:

function doDownload() {
var dlwin
dlwin =
window.open("download.aspx","dlwin","width=10,heig ht=10,dependent=yes,menuba
r=no,toolbar=no,scrollbars=no,resizable=no");
dlwin.close();
}

and changed the link to <A HREF="javascript: doDownload()">, but the
dlwin.close() command does not execute for some reason. No error is
reported.

Any advice? Any tips? Any Advil?

Thanks,

Jeff
Nov 17 '05 #1
1 1827
ok, it's not javascript that's breaking, looks like for some reason
selecting an option from a drop down list after downloading a file raises
an "access is denied" error on the client (otgher javascript code seems to
work ok). Still stumped.

I see all sorts of examples of downloading files on the web. Has no one else
had this problem?

Any help greatly appreciated.

Thanks,

Jeff

"Jeff Cooper" <js******@compudude.com> wrote in message
news:8a*****************@newsread2.news.atl.earthl ink.net...
Hey there folks,

I have a link on a page which I would like to point to string that's
downloaded as a file -- a *.tab file to be exact. The link points to a file (download.aspx) which contains no html but uses response.write to send the
data to the client who then downloads it. Problem is, unless I get the
target attribute of the link to _blank, then any javascript I have sitting
on the page gives me an "access is denied" error, but only AFTER a file is
downloaded. I can't just point the link to an existing file since the
contents to be downloaded are generated dynamically.

Below if the code from the load event of download.aspx:

'no html on this page, just that top yellow <@ page ...> line.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim S As String
'
' Bunch of code here to build string S
'
Response.Clear()
Response.ContentType = "text/tab-separated-values"
Response.AppendHeader("Content-Disposition", "attachment;filename=" &
"myfile.tab")
Response.Write(S)
Response.Close()
End Sub

As I said, if I use the tag <A HREF="download.aspx"> then the file
downloads. But, any subsequent javascript I try to execute on the same
page, gives me Access is Denied (I have a drop down list which calls a
function on the onChange event).

If I use the tag <A HREF="download.aspx" target="_blank"> then the file
downloads and I'm ok, except for a new window that's now opened.

I tried doing it all using javascript and a child window:

function doDownload() {
var dlwin
dlwin =
window.open("download.aspx","dlwin","width=10,heig ht=10,dependent=yes,menuba r=no,toolbar=no,scrollbars=no,resizable=no");
dlwin.close();
}

and changed the link to <A HREF="javascript: doDownload()">, but the
dlwin.close() command does not execute for some reason. No error is
reported.

Any advice? Any tips? Any Advil?

Thanks,

Jeff

Nov 17 '05 #2

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

Similar topics

5
by: Rami A. Kishek | last post by:
I'm new to js. Please help me figure this out WANT: Client to save an image to disk pressing a "download" button. The image name is dynamic, from JS code on another part of the page DID: Read...
3
by: Brian | last post by:
Hi I'm trying to get a small script working I need to get the user to input some info from a prompt and then use that info in a PHP script, but I can't seem to assign the JavaScript var to a...
12
by: Andrey | last post by:
Hi, I just wonder if anybody can help me with this: I need to give my javascript code some extended permissions for disk access on client's machine, and as i understand i need to sign this js....
6
by: Jim | last post by:
Group, How would I go about firing a JavaScript method from a C# method in the aspx code behind file? It seems as though this could not be done since JavaScript is executed from within the Web...
2
by: xander.zone.3x | last post by:
How can we download data in tables in a html page into a csv file using client side Javascript. I should click a button and a table's data should be downloaded into a csv in local drive. The os...
11
by: =?iso-8859-1?q?Martin_M=FCcke?= | last post by:
Hi, I am looking for a good javascript obfuscator - I found several on the web, but I am looking for one that can also handle javascript in jsp, html and java files - so I need a javascript...
3
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
Hi, This is an issue that happens to me and everybody else I know and I've never found a way around it. In Visual Studio (currently using 2003 but the same has happened for me in 2005 and...
7
by: =?Utf-8?B?QU9UWCBTYW4gQW50b25pbw==?= | last post by:
Hi, I have been using the code (some of it has been removed for simplicity) below to allow authenticated (using ASP.NET membership database) users to get a file from their archive area. It...
9
by: _Who | last post by:
I have a .htm file that shows in an iframe which is part of a master's asp:Content. I need the .htm to copy the style class from the master or set it as shown below. Below is how I set the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.