Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating a page with html blocks on load

Status
Not open for further replies.

lorax

Technical User
Apr 16, 2001
7
US
I'm trying to create a client-side DHTML app. When it loads, it needs to check the user's system for certain apps. For the ones that are found, some descriptive text and an icon with a link to launch the app will appear on the page. Is there a way to create the blocks of html needed for each app and have them displayed as the apps are found? Can insertAdjacentHTML or document.write be used to display elaborate chunks of HTML?
 
You can insert anything you like - even create whole new data structures, using document.createElement() and stuff.There is a good article I have printed, but it has no URL on it - maybe ask jaredn for the URL to a good site. You could also have just provisional document writes like:

if(thisIsTrue){
document.write("html stuff here");
}
else if(someOtherConditionisTrue){
document.write("Different HTML");
}

It's your choice really! The only problem is it takes ages to write all the code as strings. This is why creating new stuff might be better for you, just depends how elaborate I guess.
b2 - benbiddington@surf4nix.com
 
You have too many options. My favorites are:

when you don't need a reference to the elements:

oContainer.innerHTML = &quot;<div>some html</div>&quot;;

and

if you need a reference to the element you are creating:

oNewElement = document.createElement(&quot;DIV&quot;);
oContainer.appendChild(oNewElement);
oNewElement.innerHTML = &quot;some html&quot;

note: you could've used innerText for the second method above if you are using IE.... this will make it much faster.

bangers...what article do you mean? jared@eae.net -
 
Um, it's one you directed me too once, it was called SCripting for the 6.0 browsers by Scott LePera...
b2 - benbiddington@surf4nix.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top