1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

html/js: dynamic change of content

Discussion in 'Web Design & Development' started by nj2b, Apr 16, 2008.

Thread Status:
Not open for further replies.
  1. nj2b

    nj2b Thread Starter

    Joined:
    Sep 9, 2006
    Messages:
    60
    Is there a way to change the document body text in real time that will work regardless of client and without having to reload the page everytime a change is desired? I found a reference to "innerText" that *appears* to work under IE6, but it doesn't work under Firebird or Firefox, so I'm guessing it's one of MS' touches. Here's a bit of what I got to work under IE6 using the onkeypress event.

    Code:
    [size="3"]
    <head>
    <script language="javascript">
    function changeTxt() {
    
       getDocumentByID("test").innerText = some_text;
    }
    </script>
    </head>
    ...
    <body>
    <p ID="test"></p>
    </body>
    ...
    [/size]
    Is there anything comparable to that for other browsers? TIA
     
  2. Mudley

    Mudley

    Joined:
    Apr 6, 2008
    Messages:
    101
    you can use document.getElementById("test").innerHTML
     
  3. TheRobatron

    TheRobatron

    Joined:
    Oct 25, 2007
    Messages:
    551
    .innerHTML will work in most modern browsers, but remember that there will always be browsers that don't have javascript or don't support certain features, so don't rely on it for basic functionality. Another useful tag for images (which works in most browsers) is document.getElementById("something").src, which will allow you to change the source of an image.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/704231

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice