Christian Schmitt wrote:[color=blue]
> On Fri, 21 Nov 2003, Martin Honnen wrote:[color=green]
>>Christian Schmitt wrote:
>>[color=darkred]
>>>I want to write a script that (run from a file on the local HD) reads
>>>another local html-file into a variable, then make some changes to it, and
>>>then output the result in a way that makes it simple for the user to save
>>>it again. And all of this should run in any current browser, not just IE.
>>>
>>>I managed to access the code of the current document by
>>>code = document.documentElement.innerHTML
>>>
>>>But when I open another window with the file I want to edit, all I get is
>>><head></head><body></body>
>>>
>>>For the output I tried to do document.write in an output window, but I
>>>can't save the code I generate there, all I get is the sourcecode of my
>>>script page (the opener of the page I try to save). Any hints?
>>>
>>>Oh, just in case that matters, I'm using Galeon on Linux.[/color]
>>
>>This sounds all like a task for server side scripting with PHP or JSP or
>> ASP.[/color]
>
>
> This all takes place locally, the script is not on a server.[/color]
I understand that you are attempting things locally, but it sounds more
like a task to be solved with PHP or ASP or JSP as there you don't run
into the restrictions client side JavaScript has to access the file
system or any Web server.
[color=blue][color=green]
>>But I think Galeon is Mozilla based so maybe it offers
>> XMLHttpRequest
>>e.g.
>> if (typeof XMLHttpRequest != 'undefined') {
>> var httpRequest = new XMLHttpRequest();
>> httpRequest.open('GET', 'whatever.html', false);
>> httpRequest.send(null);
>> alert(httpRequest.responseText);
>> }
>>That way you can read text pages from the same server the page with the
>>script is loaded from.
>>[/color]
>
> XMLHttpRequest seems to be supported, but hangs the browser :-((
> Perhaps because I try to read a local file?[/color]
The third argument to the open() call is the asynchronous mode, in the
example above that is false meaning the send() call later will block the
beowser till the file is loaded.
You can also perform asynchronous requests, then you need to set up an
httpRequest.onreadystate
handler.
If you do not even want to read files via http but only from the local
file system then perhaps XPConnect can do that with Galeon
http://www.faqts.com/knowledge_base/...d/23360/fid/53
--
Martin Honnen
http://JavaScript.FAQTs.com/