HighDots Forums  

Can JS bring up the Open With/Save As dialog?

Javascript JavaScript language (comp.lang.javascript)


Discuss Can JS bring up the Open With/Save As dialog? in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
kj
 
Posts: n/a

Default Can JS bring up the Open With/Save As dialog? - 06-02-2008 , 07:44 AM








Hi. Suppose that a JavaScript script running on some browser has
some data in a variable (e.g. a large chunk of text retrieved via
Ajax from a remote server). Is there a way for the script to cause
the browser's Open With/Save As dialog to come up to view this
data?

TIA!

Kynn

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.

Reply With Quote
  #2  
Old   
Bjoern Hoehrmann
 
Posts: n/a

Default Re: Can JS bring up the Open With/Save As dialog? - 06-02-2008 , 08:08 AM






* kj wrote in comp.lang.javascript:
Quote:
Hi. Suppose that a JavaScript script running on some browser has
some data in a variable (e.g. a large chunk of text retrieved via
Ajax from a remote server). Is there a way for the script to cause
the browser's Open With/Save As dialog to come up to view this
data?
You could try to simulate it by navigating to an address that either has
an unknown internet media type or alternatively a 'Content-Disposition'
header with the right values (e.g., by posting the data to some web site
first). An option for the former could be:

window.location.href = 'data:application/octet-stream,...';

where the ... is the properly encoded data you wish the user to save.
You could also use whatever right mime type you have and have the user
right-click save-as, but I don't think you can trigger that from script.
--
Björn Höhrmann · mailto:bjoern (AT) hoehrmann (DOT) de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/


Reply With Quote
  #3  
Old   
Lee
 
Posts: n/a

Default Re: Can JS bring up the Open With/Save As dialog? - 06-03-2008 , 06:28 PM



On Jun 2, 7:44*am, kj <so... (AT) 987jk (DOT) com.invalid> wrote:
Quote:
Hi. *Suppose that a JavaScript script running on some browser has
some data in a variable (e.g. a large chunk of text retrieved via
Ajax from a remote server). *Is there a way for the script to cause
the browser's Open With/Save As dialog to come up to view this
data?

TIA!

Kynn

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
This may help you http://www.tek-tips.com/viewthread.c...1171273&page=1
but it looks like you may run into security issues.

Can you not write the file to the server and let the user download it
Bjoern has pointed out?


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.