473,670 Members | 2,636 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventArg s) Handles MyBase.Load
Dim S As String
'
' Bunch of code here to build string S
'
Response.Clear( )
Response.Conten tType = "text/tab-separated-values"
Response.Append Header("Content-Disposition", "attachment;fil ename=" &
"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("do wnload.aspx","d lwin","width=10 ,height=10,depe ndent=yes,menub a
r=no,toolbar=no ,scrollbars=no, resizable=no");
dlwin.close();
}

and changed the link to <A HREF="JavaScrip t: 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 1843
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******@compu dude.com> wrote in message
news:8a******** *********@newsr ead2.news.atl.e arthlink.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.EventArg s) Handles MyBase.Load
Dim S As String
'
' Bunch of code here to build string S
'
Response.Clear( )
Response.Conten tType = "text/tab-separated-values"
Response.Append Header("Content-Disposition", "attachment;fil ename=" &
"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("do wnload.aspx","d lwin","width=10 ,height=10,depe ndent=yes,menub a r=no,toolbar=no ,scrollbars=no, resizable=no");
dlwin.close();
}

and changed the link to <A HREF="JavaScrip t: 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
30201
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 somewhere I can use document.execCommand("SaveAs") to do it This solves it for MSIE, at least. My code is below PROBLEM: What actually happens with MSIE is: 1) A window pops up promting me to save as.
3
2339
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 PHP var <?PHP if ($do == 'ban') {
12
8493
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. Can someone tell me how to sign js to work with with ie? Can i put my js file into jar and use jarsigner for that? And by the way, would it give me disk access permissions? I need that for the following: our client gets a cd from us with some mp3...
6
4497
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 browser and C# is executed on the server. Thanks for your consideration, Jim
2
15710
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 used is m$ windows..
11
5163
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 obfuscator that handles my entire web project. Is there anything like that, preferable as a Eclipse plugin? Thanks,
3
2956
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 2008 as well) If I put a breakpoint in a .js file, the debugger picks it up and breaks into it at that point.
7
2818
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 seems to work fine, however I noticed that no web log entry is added when a successful download occurs (normally a 200 HTTP status code, however, if there is an authorization failure, it gets logged). I have a logging routine that logs a successful...
9
2575
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 stylesheet in the master. What I'd like to do, is change that code into javascript and run it in the
0
8901
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8814
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7415
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6213
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5683
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4209
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2799
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 we have to send another system
2
2041
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1792
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.