Magazine |
| | Community |
| | Workshop |
| | Tools & Samples |
| | Training |
| | Site Info |
|
|
||||||||
|
Sets or retrieves the current object and its content in HTML.
Syntax
HTML N/A Scripting object.outerHTML [ = sHTML ]
Possible Values
sHTML String containing content and HTML tags. The property is read/write with no default value.
Remarks
The property can be any valid string containing a combination of text and tags, except for the HTML, HEAD, and TITLE tags.
When setting the property, the given string completely replaces the object, including its start and end tags. If the string contains HTML tags, the string is parsed and formatted as it is placed into the document.
The property cannot be set while the document is loading. Wait for the onload event before attempting to set it. If a tag is dynamically created using TextRange, innerHTML, or outerHTML, use JScript™ (compatible with ECMA 262 language specification) to create new events to handle the newly formed tags. VBScript is not supported.
OuterHTML is read-only on the following objects: TBODY, TD, TFOOT, TH, THEAD, TR.
Example
The following example demonstrates use of the outerHTML property to copy an object, accompanying attributes, and children to a list when a user clicks one of the objects.
Sample Code
<SCRIPT> function fnCopyHTML(){ var oWorkItem = event.srcElement; if((oWorkItem.tagName != "UL") && (oWorkItem.tagName != "LI")){ alert("Adding " + oWorkItem.outerHTML + " to the list."); oScratch.innerHTML += oWorkItem.outerHTML + "<BR>"; } } </SCRIPT> <UL onclick = "fnCopyHTML()"> <LI><B>Bold text</b> <LI><I>Italic text</I> <LI><U>Underlined text</i> <LI><STRIKE>Strikeout text</STRIKE> </UL> <P> <DIV ID = "oScratch" > </DIV>
Applies To
A, ACRONYM, ADDRESS, APPLET, AREA, B, BDO, BGSOUND, BIG, BLOCKQUOTE, BR, BUTTON, CENTER, CITE, CODE, COMMENT, DD, DEL, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, Hn, HR, HTMLAREA, I, IFRAME, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=hidden, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, NEXTID, NOBR, OBJECT, OL, P, PLAINTEXT, PRE, Q, RB, RT, RUBY, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, WBR, XMP
See Also
Does this content meet your programming needs? Write us!
© 1998 Microsoft Corporation. All rights reserved. Terms of use.