File I/O 
January 25th, 2007, 11:25 AM
| | | |
This may be simple but as a JavaScript beginner I am having trouble writing
and saving to a file.
I am trying to use the Google AJAX search API. Within a
<script type="text/javascript" ...I have a searcher for GwebSearch.
Once executed I assign
var result = searcher.results[i];
I then
alert(result.url);
(all properties of the searcher are not important here).
My question is how to save the result.url to a file instead of sending
to the screen. I guess it comes down to doing File I/O within JavaScript.
If someone advise, or better yet point me to an example where file I/O
is done within a HTML <scriptit would be greatly appreciated.
Thank you.
- Andrew M. Neiderer | 
January 25th, 2007, 12:55 PM
| | | | re: File I/O
Andrew Neiderer wrote: Quote:
If someone advise, or better yet point me to an example where file I/O
is done within a HTML <scriptit would be greatly appreciated.
| Script run within the browser sandbox has no file system access with
normal security settings.
--
Martin Honnen http://JavaScript.FAQTs.com/ | 
January 25th, 2007, 06:45 PM
| | | | re: File I/O
Martin Honnen wrote: Quote:
Andrew Neiderer wrote: Quote:
>If someone advise, or better yet point me to an example where file I/O
>is done within a HTML <scriptit would be greatly appreciated.
| Script run within the browser sandbox has no file system access with
normal security settings.
| In plain English, there is no way to write to a user’s system. Ifyou
need to save a file, you should use AJAX and have a service on the web
server interact with your JavaScript, so that data can be dynamically
saved by the JS for that user in that session. From there, you can have
the file “download” to the user’s system. However, the user still has to
approve this action (it cannot be automated).
In other words, the JS passes the data to the web service that is
running on the web server, and the web server can then do what it wants
with that data, including providing it to the user as a download.
I hope this helps.
...Geshel
--
************************************************** *******************
My e-mail address is an automatically monitored spam honeypot. Do not
send e-mail there unless you wish to be reported as a spammer. Please
send e-mail to my first name at my last name dot org.
************************************************** ******************* | 
January 25th, 2007, 10:35 PM
| | | | re: File I/O
Neo Geshel said the following on 1/25/2007 1:32 PM: Quote:
Martin Honnen wrote: Quote:
>Andrew Neiderer wrote:
>> Quote:
>>If someone advise, or better yet point me to an example where file I/O
>>is done within a HTML <scriptit would be greatly appreciated.
| >>
>Script run within the browser sandbox has no file system access with
>normal security settings.
>>
| In plain English,
| And what exactly in Martin's reply wasn't "plain English". It was quite
plain.
there is no way to write to a users system. If you Quote:
need to save a file, you should use AJAX and have a service on the web
server interact with your JavaScript, so that data can be dynamically
saved by the JS for that user in that session.
| In "plain English", using AJAX to save a file locally is a stupid way to
do it.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ | 
January 26th, 2007, 08:45 PM
| | | | re: File I/O
Randy Webb wrote: Quote:
Neo Geshel said the following on 1/25/2007 1:32 PM: Quote:
>Martin Honnen wrote: Quote:
>>Andrew Neiderer wrote:
>>>
>>>If someone advise, or better yet point me to an example where file I/O
>>>is done within a HTML <scriptit would be greatly appreciated.
>>>
>>Script run within the browser sandbox has no file system access with
>>normal security settings.
>>>
| >In plain English,
| And what exactly in Martin's reply wasn't "plain English". It was quite
plain.
| Some people that I know that do web sites (for a hobby, mind you) think
that a sandbox is what children play in. Pair it with “browser”, and
you’ve just caused their eyes to glaze over.
Martin’s reply was techspeak. Light techspeak to be sure, but farfrom
“plain English”. Quote:
there is no way to write to a user�s system. If you Quote:
>need to save a file, you should use AJAX and have a service on the web
>server interact with your JavaScript, so that data can be dynamically
>saved by the JS for that user in that session.
| In "plain English", using AJAX to save a file locally is a stupid way to
do it.
| So where is your recommendation?
If you’re going to bash someone about their methods, back it up with a
method that’s “better”, at least in your opinion.Otherwise you’re just
a loudmouthed boor at best, and an idiot at worst.
Cheers.
...Geshel
--
************************************************** *******************
My return e-mail address is an automatically monitored spam honeypot.
Do not send e-mail there unless you wish to be reported as a spammer.
Please send all e-mail to my first name at my last name dot org, with
a subject-line of “NEWSGROUP REPLY FOR NEO GESHEL” (all uppercase).
************************************************** ******************* | 
January 26th, 2007, 09:15 PM
| | | | re: File I/O
Neo Geshel said: Quote:
>
>Randy Webb wrote: Quote:
>Neo Geshel said the following on 1/25/2007 1:32 PM: Quote:
>>Martin Honnen wrote:
>>>Andrew Neiderer wrote:
>>>>
>>>>If someone advise, or better yet point me to an example where file I=
| | >/O Quote: Quote:
>>>>is done within a HTML <scriptit would be greatly appreciated.
>>>>
>>>Script run within the browser sandbox has no file system access with =
| | > Quote: Quote:
>>>normal security settings.
>>>>
>>In plain English,
| >>=20
>And what exactly in Martin's reply wasn't "plain English". It was quite=
| >=20>
>Some people that I know that do web sites (for a hobby, mind you) think=20
>that a sandbox is what children play in. Pair it with =E2=80=9Cbrowser=E2=
>=80=9D, and=20
>you=E2=80=99ve just caused their eyes to glaze over.
| Within the context of this newsgroup, there's nothing overly techinical
about "browser". The word "sandbox" is a metaphor for any restricted
area of operation. It's use is not restricted to techspeak. Quote: Quote:
> there is no way to write to a user=EF=BF=BDs system. If you Quote: |
>>need to save a file, you should use AJAX and have a service on the web=
| | >=20 Quote: Quote: |
>>server interact with your JavaScript, so that data can be dynamically =
| | > Quote: Quote: |
>>saved by the JS for that user in that session.=20
| >>=20
>In "plain English", using AJAX to save a file locally is a stupid way t=
| >o=20>
>So where is your recommendation?
>
>If you=E2=80=99re going to bash someone about their methods, back it up w=
>ith a=20
>method that=E2=80=99s =E2=80=9Cbetter=E2=80=9D, at least in your opinion.=
Otherwise you=E2=80=99re just=20
>a loudmouthed boor at best, and an idiot at worst.
| He told you that there's no way to write to a user's system.
That sort of absolves him from having to provide a method,
don't you think?
By the way, quoted-printable is a poor choice for posts to USENET.
-- | 
January 28th, 2007, 03:05 AM
| | | | re: File I/O
Neo Geshel said the following on 1/26/2007 3:41 PM: Quote:
Randy Webb wrote: Quote:
>Neo Geshel said the following on 1/25/2007 1:32 PM: Quote:
>>Martin Honnen wrote:
>>>Andrew Neiderer wrote:
>>>>
>>>>If someone advise, or better yet point me to an example where file I/O
>>>>is done within a HTML <scriptit would be greatly appreciated.
>>>>
>>>Script run within the browser sandbox has no file system access with
>>>normal security settings.
>>>>
>>In plain English,
| >>
>And what exactly in Martin's reply wasn't "plain English". It was
>quite plain.
| >
Some people that I know that do web sites (for a hobby, mind you) think
that a sandbox is what children play in. Pair it with “browser”, and
you’ve just caused their eyes to glaze over.
| Then maybe they should spend an hour or so on Google and learn some
things about the hobby they have chosen to partake. Quote:
Martin’s reply was techspeak. Light techspeak to be sure, but far from
“plain English”.
| No, it was quite plain. You have no access in a default security
environment to save to the local file system from a webpage. Now, are
you going to glaze eyes over with people thinking that "environment" is
the confines of the space you live in? Quote: Quote:
> there is no way to write to a user�s system. If you Quote:
>>need to save a file, you should use AJAX and have a service on the
>>web server interact with your JavaScript, so that data can be
>>dynamically saved by the JS for that user in that session.
| >>
>In "plain English", using AJAX to save a file locally is a stupid way
>to do it.
>>
| >
So where is your recommendation?
| Considering that you can't do what was asked - in a default security
environment - then there isn't much to recommend other than to say "Find
some other way to make your page works that is feasible". Quote: |
If you’re going to bash someone about their methods,
| I didn't bash you, I called the idea stupid and it still is.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,689 network members.
|