> I need help in writing a js to launch a browser's File-Save-As dialog
> box. TIA, Herb
alert('Please rightclick and do a save as.');
No, only possible with serverside!! javascript and streaming.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
> wrote on 07 mrt 2009 in comp.lang.javascript:
>
>> I need help in writing a js to launch a browser's File-Save-As dialog
>> box. TIA, Herb
>
>alert('Please rightclick and do a save as.');
>
>No, only possible with serverside!! javascript and streaming.
Thank you.
Herb
document.execCommand("SaveAs");
But that's MSHTML-only. STFW.
PointedEars
it will recognise its not a web page, and automagically ask if you want
to download it.
> Evertjan. wrote:
>> wrote on 07 mrt 2009 in comp.lang.javascript:
>>
>>> I need help in writing a js to launch a browser's File-Save-As dialog
>>> box. TIA, Herb
>>
>> alert('Please rightclick and do a save as.');
>>
>> No, only possible with serverside!! javascript and streaming.
>>
>>
> No need for javascript or streaming whatever that is.
Yes, there is an obvious "need" for Javascript,
because that was what was asked for.
I am sorry you do not know about streaming.
> Simply send the relevant file with mime headers to the browser, and
> it will recognise its not a web page, and automagically ask if you want
> to download it.
>The Natural Philosopher wrote on 08 mrt 2009 in comp.lang.javascript:
>
>> Evertjan. wrote:
>>> wrote on 07 mrt 2009 in comp.lang.javascript:
>>>
>>>> I need help in writing a js to launch a browser's File-Save-As dialog
>>>> box. TIA, Herb
>>>
>>> alert('Please rightclick and do a save as.');
>>>
>>> No, only possible with serverside!! javascript and streaming.
>>>
>>>
>> No need for javascript or streaming whatever that is.
>
>Yes, there is an obvious "need" for Javascript,
>because that was what was asked for.
Yes, because I want to put a button a page that allows the user to save
the currently viewed page to a local location and with a filename chosen
by the user.
>
>I am sorry you do not know about streaming.
>
>> Simply send the relevant file with mime headers to the browser, and
>> it will recognise its not a web page, and automagically ask if you want
>> to download it.
>
I'm not trying to download and save a remote file. I have an HTML report
generated with a Perl script, and I want the user to be able to press a
clearly labeled button at the bottom of the page and bring up the
file-save dialog. (My users have shown they do not understanding that all
they have to do is click on File/SaveAs. No matter how many times they are
told how to save the page.)
--
Ed Jay (remove 'M' to reply by email)
Win the War Against Breast Cancer.
Knowing the facts could save your life.
http://www.breastthermography.info
> Evertjan. wrote:
>
>>The Natural Philosopher wrote on 08 mrt 2009 in comp.lang.javascript:
>>
>>> Evertjan. wrote:
>>>> wrote on 07 mrt 2009 in comp.lang.javascript:
>>>>
>>>>> I need help in writing a js to launch a browser's File-Save-As
>>>>> dialog box. TIA, Herb
>>>>
>>>> alert('Please rightclick and do a save as.');
>>>>
>>>> No, only possible with serverside!! javascript and streaming.
>>>>
>>>>
>>> No need for javascript or streaming whatever that is.
>>
>>Yes, there is an obvious "need" for Javascript,
>>because that was what was asked for.
>
> Yes, because I want to put a button a page that allows the user to
> save the currently viewed page to a local location and with a filename
> chosen by the user.
No.
You do not need clientside Javascript for that, because clientside
Javascript cannot do that.
But if you want to use Javascript you can use SERVERSIDE Javascript to
insert the necessary mime headers.
>>I am sorry you do not know about streaming.
>>
>>> Simply send the relevant file with mime headers to the browser, and
>>> it will recognise its not a web page, and automagically ask if you
>>> want to download it.
>>
> I'm not trying to download and save a remote file. I have an HTML
> report generated with a Perl script, and I want the user to be able to
> press a clearly labeled button at the bottom of the page and bring up
> the file-save dialog.
That being a serverside file or stream,
I do not understand what you are NOT trying to do.
> (My users have shown they do not understanding
> that all they have to do is click on File/SaveAs. No matter how many
> times they are told how to save the page.)
--
Works like a peach. Hit button. Browsers says 'what do you want to do'
and the file gets downloaded or sent to a PDF viewer. No need for
javascript at all.
I guess you could do th same with HTML by encapsulated it on non HTML
headers.
I guess perl is as bad a language to do it in as anything else, as well.
> I have an HTML report
>generated with a Perl script, and I want the user to be able to press a
>clearly labeled button at the bottom of the page and bring up the
>file-save dialog. (My users have shown they do not understanding that all
>they have to do is click on File/SaveAs. No matter how many times they are
>told how to save the page.)
Then you can have a button which opens a pop-up, or un-hides a DIV
following the button, so that instructions for "File / Save as" are
shown.
In this case, browser-sniffing may be justified, since there may be no
File menu CChrome) ; "right-click / Save As" might be better, but you
may want to match the wording exactly to known browsers.
--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.
Right, there is no way to bring up "Save As".
Would be useful.
Instead, the data would have to be round-tripped; sent to the server,
then back to the client with the appropriate headers.
Garrett
--
comp.lang.javascript FAQ <URL: http://jibbering.com/faq/ >
Yes, there is.
> Would be useful.
Or annoying, which might be why other vendors did not implement it.
> Instead, the data would have to be round-tripped; sent to the server,
> then back to the client with the appropriate headers.
No.
PointedEars
OK, so how do you bring up the Save as, without sending data to the server?
And as he so graciously points out:
But that's MSHTML-only. STFW.
--
Tyler Style
http://malthusian-solutions.com
http://nirdvana.com
As usual, it is not justified.
> File menu CChrome) ; "right-click / Save As" might be better, but you
Chrome doesn't have a file menu? Regardless, neither does MSHTML
under some circumstances (e.g. embedded in an application that lacks a
file menu.)
> may want to match the wording exactly to known browsers.
First you would have to know what browser you are dealing with. The
UA string won't tell you for sure, so you are pretty much out of luck
on compiling a database of UI semantics per UA string. The answer is
to present both sentences to everybody.
As Thomas pointed out, IE can do what the OP wants, so conditional
comments and/or a check for the proprietary method, could be used to
present an alternate button for IE that actually performs the task of
opening the dialog. I think I would wrap such a thing in a try-catch
clause in case there is a security configuration that prevents the
action.
You've not tried Chrome? I thought you were a professional developer.
My Chrome has no visibly-named menus; Save As is found by clicking the
rectangle which has a corner folded over (and no representation of
writing on it), which is next to the spanner.
>> may want to match the wording exactly to known browsers.
>
>First you would have to know what browser you are dealing with. The
>UA string won't tell you for sure, so you are pretty much out of luck
>on compiling a database of UI semantics per UA string.
There is no need to rely on the UA string. Any browser that has
"navigator.vendor = Google Inc." is asking to be treated as Chrome.
> The answer is
>to present both sentences to everybody.
Verbose. "Select the 'File' menu, press the Context Menu key, or right-
click; then select 'Save As' or 'Save Page As' or similar; then select
the appropriate Type and file Name." The OP will need to check the
wording on "all" browsers, or rely on at least a modicum of user
intelligence; the former seems more reliable.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
Of course I've tried Chrome. And IIRC, like virtually all
applications, it had a file menu.
> My Chrome has no visibly-named menus; Save As is found by clicking the
> rectangle which has a corner folded over (and no representation of
> writing on it), which is next to the spanner.
Good luck with that.
>
> >> may want to match the wording exactly to known browsers.
>
> >First you would have to know what browser you are dealing with. The
> >UA string won't tell you for sure, so you are pretty much out of luck
> >on compiling a database of UI semantics per UA string.
>
> There is no need to rely on the UA string. Any browser that has
> "navigator.vendor = Google Inc." is asking to be treated as Chrome.
And what can you infer about future versions of Chrome?
[snip]