pasteHTMLpasteHTML*
*Contents  *Index  *Topic Contents
*Previous Topic: parentElement
*Next Topic: previousPage

pasteHTML

Description

Pastes HTML text into the given text range. The text completely replaces any previous text and HTML elements in the range.

Syntax

object.pasteHTML(htmlText)

ParameterDescription
htmlText String specifying the HTML text to paste. The string can contain text and any combination of the HTML tags described in HTML Elements.

Return Value

No return value.

Remarks

Although this method never fails, it might alter the HTML text to make it fit the given text range. For example, attempting to paste a table cell into a text range that does not contain a table might cause the method to insert a TABLE element. For predictable results, you should paste only well-formed HTML text that is appropriate for the given text range.

Note You cannot use this method while the document is loading. Wait until the document is completely downloaded.

Remarks

This feature might not be available on non-Win32 platforms. See article Q172976 in the Microsoft Knowledge Base for the latest information on Internet Explorer cross-platform compatibility.

Example

The following JScript example replaces the current selection with a new paragraph.

var sel = document.selection;
if (sel!=null) {
    var rng = sel.createRange();
    if (rng!=null)
        rng.pasteHTML("<P><B>Selection has been replaced.</B>");
}

Applies To

TextRange


Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.