homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Dynamically Updating Body Text with Javascript
How would you add to the body text after a page has loaded?

 1:29 pm on Jun 13, 2003 (gmt 0)

I've got a program written in javascript that takes a while to load and I want to display the output sequentially, rather than making the user wait until the program has completed. Is there a good way, using javascript, to update the body text after the page has loaded?



 4:30 pm on Jun 13, 2003 (gmt 0)

write() method


 4:31 pm on Jun 13, 2003 (gmt 0)



 10:20 am on Jun 14, 2003 (gmt 0)

Take care... If you use document.write() after the page has loaded it will completely rewrite (i.e. obliterate) the page, not append to it...

To "...update the body text after it has loaded...", do as follows:

Say in your html you have <div id="blah">some text</div>

Then in your javascript which gets executed using the onload method:
document.getElementById("blah").innerHTML = "Different Text";

Also, you can add child nodes (e.g. divs or whatever tag you want) with createElement() and appendChild()
e.g. say you have <div id="table_holder"> </div>
Then you can do:
var table_div = document.getElementById("table_holder");
var table_to_insert = document.createElement("table");

Similarly, you can add tr's as children of the table_to_insert and td's as their children... or whatever tags you want to add.

Note that all this may not help with your initial problem (getting the page to load faster). All the javascript needs to get downloaded... Describe what you are trying to do in more detail, and someone may be able to offer more help.

Hope that makes sense



 11:54 am on Jun 14, 2003 (gmt 0)

You could look into innerHTML for this.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved