Read HTML-code from file (2nd attempt)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christian Schmitt

    Read HTML-code from file (2nd attempt)

    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.docume ntElement.inner HTML

    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.doc ument.documentE lement.innerHTM L

    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
  • Mark Szlazak

    #2
    Re: Read HTML-code from file (2nd attempt)

    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!

    Comment

    • SanJoseWebGuy

      #3
      Re: Read HTML-code from file (2nd attempt)

      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

      Comment

      Working...