Using JS "WRITE" type functionality without erasing the original page.

Discussion in 'Javascript' started by Eric, Jul 21, 2003.

  1. Eric

    Eric Guest

    Is it possible? I'm trying to add to the current page -- but add at a
    specific point. Can add HTML tags from javascript midway through the page
    (at a place I specify) without erasing the existing page?

    Thanks,
    Eric
     
    Eric, Jul 21, 2003
    #1
    1. Advertising

  2. Eric

    Eric Guest

    Right -- but DOM2 isn't universally supported (not that javascript is -- but
    I wanted to do a little bit better than IE5). Is this my only option?

    Thanks,
    Eric
     
    Eric, Jul 21, 2003
    #2
    1. Advertising

  3. "Eric" <> writes:

    Please keep a little of the post you are answering so we can see wha
    you refer to.

    > Right -- but DOM2 isn't universally supported (not that javascript is -- but
    > I wanted to do a little bit better than IE5).


    What does IE5 do, and what would be better?

    > Is this my only option?


    (the one in the FAQ?)

    It is a *good* option. It works in IE4+, NS6+ and Opera 7.

    The code is not very pretty, though. Try this instead:
    ---
    function writeHTML(id,S) {
    var elem = (document.getElementById ? document.getElementById(id) :
    (document.all ? document.all[id] : undefined));
    if (!elem) { return false; }
    elem.innerHTML = S;
    return true;
    }
    ---
    It works in any browser that understands .innerHTML. Adding support
    for NS4 requires some extra work, but is possible if the element
    to write into is absolutely positioned.

    I don't know what other browsers are out there that allows changing
    the contents of the page dynamically.

    /L
    --
    Lasse Reichstein Nielsen -
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, Jul 21, 2003
    #3
  4. Eric

    Chris Wright Guest

    On Mon, 21 Jul 2003 00:02:17 -0700, "Eric" <> wrote:

    >Right -- but DOM2 isn't universally supported (not that javascript is -- but
    >I wanted to do a little bit better than IE5). Is this my only option?
    >

    If you don't want to use innerHTML etc. then you could include a
    JavaScript document.write() in the HTML document at the appropritate
    point.

    If you need to alter is after the HTML page hase rendered then reload
    the page with the variables driving the document.write() primed to
    include the new data.

    This might require using data saved in another frame, or cookie etc.

    HTH
     
    Chris Wright, Jul 21, 2003
    #4
  5. Eric

    Eric Guest

    I never even thought of placing the document.write statement within the
    document as opposed to the beginning or end of the document.

    Thanks!
     
    Eric, Jul 21, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stu
    Replies:
    2
    Views:
    796
    Rob McAninch
    Apr 6, 2004
  2. darrel
    Replies:
    4
    Views:
    555
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    May 5, 2006
  3. Chuck
    Replies:
    0
    Views:
    266
    Chuck
    Jul 5, 2003
  4. Junhui Liao
    Replies:
    3
    Views:
    169
    Colin Bartlett
    Jul 27, 2010
  5. mike
    Replies:
    4
    Views:
    100
    Dr.Ruud
    Mar 3, 2009
Loading...

Share This Page