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!

Writing to a DIV 1

Status
Not open for further replies.

yahve

Programmer
Nov 14, 2000
159
CA
Hi,

I'm trying to rewrite the content of a DIV live. No problem with IE as I use innerText or innerHTML. Under NS4, what would be the prefered way to do this. Can I use the ID attribute of the DIV or do I need to use a NAME attribute.
I would prefer not to use the SRC attribute of the DIV since I do not want the page to refresh when the content changes.

Thanks.
Un fromage havarti en vaut deux.
 
document.layers.layername.document.write("some content") jared@aauser.com
 
Hi,

Thank you both. Can I assume that both methods are equivalent. Does that mean that for NS4+ I can write to <DIV ID=&quot;thisdiv&quot;> like so:
thisdiv.document.write(&quot;text&quot;);

Thanks
Un fromage havarti en vaut deux.
 
I don't think so, think you'd have to use:

<DIV name=&quot;thisdiv&quot;></div>
document.layers.thisdiv.document.write(&quot;text&quot;);
jared@aauser.com
 
I'm not positive, but I believe you can reference layers directly by name. Give it a try and see if it works or not. If not, like Jared suggested, reference the name out of the layers object in NS and the all object in IE -- also, you could do this: if (!document.all) {document.all = document.layers;}. That would let you use document.all.thisdiv in both IE and NS.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top