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!

Messing with HTML (May be common knowledge)

Status
Not open for further replies.

ACRRHODES

Programmer
May 16, 2000
33
CA
You can mess with any named(or arrayed, such as links) HTML tags with the &quot;innerHTML&quot; and &quot;outerHTML&quot; commands.<br>innerHTML refers to all of the HTML within the tags, and outerHTML refers to all of the HTML within the tags, plus the tags themselves.<br>Example:<br>document.links[0].innerHTML = &quot;&lt;b&gt;New Text Placed Here&lt;\/b&gt;&quot;<br>document.all.myspan.outerHTML = &quot;&quot; //deleted the span
 
adding onto that, could you at one time delete a div (using the line mentioned in the previous post), and then later write it back in? using:<br><br>document.all.myspan.outerHTML=&quot;&lt;div id=myspan&gt;&quot;;<br><br>just wondering. <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
I've never tried it before, but you should probably just delete the innerHTML to be safe.
 
about innerHTML and outerHTML - you should be aware that this is only IE specific.<br><br>about deleteing and creating the div - i also didn't try this, but suppose that it is possible to delete it, but not recreate, because after that it is deleted, the element don't exist anymore and can't be reffered with document.all.id.<br>outerHTML is usefull if you want change dynamicly some of the properties of the element which you refer to, but often there are also better possibilities to do this.
 
Yes, I was wondering what other ways there are to do this.
 
you can do it also using the style element :<br>object.style.display=&quot;none&quot; (or =&quot;block&quot; if you want it visible again) [where object is something like document.all.myspan]<br>i've done it and it works fine - it's on ie tho, i don't know if it'll be ok with netscape - let me know ;) !<br><br>
 
style.display = &quot;block&quot; and style.display = &quot;none&quot; do not work in Netscape (most things that involve dynamically re-drawing the page don't), also these do not actually delete the element they just toggle the display. The element is still there in fact in IE4 (but not 5) you actually tab through form elements that have been hidden this way you just cannot see the focused element. You can also use display = &quot;inline&quot; for elements that are not block elements.<br>If you are targeting IE only you can toggle whole sections of the page in this way creating the appearance of a multi-page form in one page.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top