By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,819 Members | 1,459 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,819 IT Pros & Developers. It's quick & easy.

Read HTML-code from file (2nd attempt)

P: n/a
Hi,

I posted this on Friday, but didn't get a satisfactory answer. Therefoer I
post it again with some clarifications.

I want to write a script that (run from a file on the local HD,
therefore I can't use server-side stuff) 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>
if I do code = otherWindow.document.documentElement.innerHTML

Is there no easy way to do this?!?

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). I don't want to
save under script-control, but manually by clicking Save-As. If there
is no simple solution to this, I still can write the code to a textarea
and have the user copy and paste it into an editor. So the most
important part is reading the code. But I'd like to have it a bit more
comfortable. Any hints?

Oh, just in case that matters, I'm using Galeon on Linux.
But I want this to run also in other browsers, so I can't use
browser-specific code. If nothing else helps and you can help me with
specific code for different browsers I could probably use browser
detection, but I would prefer to keep it simple.

I hope someone out there can help me.

Thanks
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
As far as I know, there really is no browser independent way to do this
even when using Java. Mozilla seems to hang when using Java for file
reads, etc.

You're stuck with IDing the browser and branching to the appropriate
code. Martin Honnen has given a link to a page I posted on how one can
do local reads in Mozilla, he also has posted many times the code for IE
and NN4 that does file i/o in this news group. Jim Ley also has an FAQ
that is posted here many times and references his page on how to get a
file into a variable using and XMLHTTPRequest.

See if Java works for other browsers.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #2

P: n/a
Christian,
I created something for you to use in MSIE only, but my emails and attachments
have been bounced back as 'server not accepting mail'. Please contact me if
you read this and let me know a working email address I can send the code to.

Jim
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.