document.write

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Trevor Stapleton

    document.write

    can anyone tell me how to stop the document.write opening a new window
    when called in a function, what I want to do is really simple but is
    is defeating at every turn.
    I have a line of text that is a link on an html page, when clicked i
    want the the function called to print a name, imediatly after the
    calling link (on the same page) please help whilst I still have some
    hair left.

    TIA
    Trevor
  • Dennis M. Marks

    #2
    Re: document.write

    I have read the following message from Trevor Stapleton
    <trevor.staplet on@ntlworld.com >
    and have decided to lend my vast knowledge.

    The writer said:[color=blue]
    > can anyone tell me how to stop the document.write opening a new window
    > when called in a function, what I want to do is really simple but is
    > is defeating at every turn.
    > I have a line of text that is a link on an html page, when clicked i
    > want the the function called to print a name, imediatly after the
    > calling link (on the same page) please help whilst I still have some
    > hair left.
    >
    > TIA
    > Trevor
    >[/color]

    and my reply is:
    A document.write done after the page has been displayed always replaces
    the entire page including any scripts that were in the page. You will
    need some other method such as a form or iFrame. You can also
    dynamically replace a division using the innerHTML function but I have
    not had much success with it.

    --
    Dennis M. Marks

    Replace domain.invalid with dcsi.net


    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

    Comment

    • McKirahan

      #3
      Re: document.write

      "Trevor Stapleton" <trevor.staplet on@ntlworld.com > wrote in message
      news:is3i30pt6e v3v4iau064m2h6q h317bp04d@4ax.c om...[color=blue]
      > can anyone tell me how to stop the document.write opening a new window
      > when called in a function, what I want to do is really simple but is
      > is defeating at every turn.
      > I have a line of text that is a link on an html page, when clicked i
      > want the the function called to print a name, imediatly after the
      > calling link (on the same page) please help whilst I still have some
      > hair left.
      >
      > TIA
      > Trevor[/color]

      Consider the use of ".innerHTML ":

      <html>
      <head>
      <title>inner.ht m</title>
      <script type="text/javascript">
      function inner() {
      results.innerHT ML = "<b>" + document.forms[0].text.value + "</b>";
      }
      </script>
      </head>
      <body onload="documen t.forms[0].text.focus()">
      Type something and press "Enter".
      <br>
      <form>
      <input type="text" name="text" onblur="inner() "> &nbsp;
      <span id="results" />
      </form>
      </body>
      </html>


      Comment

      • Thomas Mlynarczyk

        #4
        Re: document.write

        Also sprach Dennis M. Marks:
        [color=blue]
        > You will need some other method such as a form or iFrame. You can also
        > dynamically replace a division using the innerHTML function but I have
        > not had much success with it.[/color]

        <a href="coolpage. html" onclick="addTex t(this); return false;">Click
        here!</a>
        <br>
        <a href="coolpage. html" onclick="addTex t(this); return false;">And here!</a>

        function addText(x) {
        x.innerHTML += ' Ah, that feels good!';
        }

        This should work on modern browsers. The return false is just for testing -
        it prevents "coolpage.h tml" from being loaded (thus disabling the link) -
        but without it, you wouldn't see any result as coolpage would load
        immediately.


        Comment

        Working...