Connecting Tech Pros Worldwide Help | Site Map

trying to open a save dialog box using javascript

Newbie
 
Join Date: Aug 2008
Posts: 1
#1: Aug 21 '08
I want to open a save dialog box instead of bringing up the file's data within the browser. I have read in other posts how to do that, but I am having problems with it. The file contents is still opening up within the browser. Below is my code. Any help will be appreciated.
Expand|Select|Wrap|Line Numbers
  1. <%@ Language="JavaScript"%>
  2. <% Response.expires = 0 %>
  3.  
  4.  
  5. <%
  6.  
  7. var szFile;
  8. if(String(Request("dataFile")) != "undefined") { 
  9.   szFile = String(Request("dataFile"));
  10. }
  11.  
  12.     Response.ContentType="application/save";
  13.     Response.AddHeader("Content-Disposition","attachment; filename = szFile")
  14.     Response.Redirect(szFile);
  15.  
  16. %>
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#2: Aug 22 '08

re: trying to open a save dialog box using javascript


I think the problem is the redirect, I think that overwrites the http header. Can you open the file using a binary stream and send it to them at that point rather than redirecting? I could do it in vbscript, but I don't think I know how to do it in javascript.

Jared
Reply