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

    Sep 9, 2006
    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.

    <script language="javascript">
    function changeTxt() {
       getDocumentByID("test").innerText = some_text;
    <p ID="test"></p>
    Is there anything comparable to that for other browsers? TIA
  2. Mudley


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


    Oct 25, 2007
    .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!

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