Connecting Tech Pros Worldwide Help | Site Map

File I/O

  #1  
Old January 25th, 2007, 11:25 AM
Andrew Neiderer
Guest
 
Posts: n/a
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


  #2  
Old January 25th, 2007, 12:55 PM
Martin Honnen
Guest
 
Posts: n/a

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/
  #3  
Old January 25th, 2007, 06:45 PM
Neo Geshel
Guest
 
Posts: n/a

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.
************************************************** *******************
  #4  
Old January 25th, 2007, 10:35 PM
Randy Webb
Guest
 
Posts: n/a

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/
  #5  
Old January 26th, 2007, 08:45 PM
Neo Geshel
Guest
 
Posts: n/a

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).
************************************************** *******************
  #6  
Old January 26th, 2007, 09:15 PM
Lee
Guest
 
Posts: n/a

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
Quote:
>plain.
>
>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
Quote:
>do it.
>>=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.


--

  #7  
Old January 28th, 2007, 03:05 AM
Randy Webb
Guest
 
Posts: n/a

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/
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot load project file in VS .NET 2003 thjwong@gmail.com answers 0 January 27th, 2006 04:35 PM
Problem with wrapping an unmanaged C++ DLL using the header file Lokkju answers 0 November 17th, 2005 03:18 PM
large file support Joseph answers 7 July 22nd, 2005 11:26 PM
Email with file attachements - How to upload file to server from browser? Dave Smithz answers 5 July 17th, 2005 01:45 PM
Help debugging Flat File Picture Gallery matt answers 2 July 17th, 2005 11:41 AM