EN
Dieser Inhalt ist in Ihrer Sprache leider nicht verfügbar. Im Folgenden finden Sie die englische Version.

pasteHTML method

Pastes HTML text into the given text range, replacing any previous text and HTML elements in the range.

Syntax

var retval = TextRange.pasteHTML(html);

Parameters

html [in]

Type: String

String that specifies the HTML text to paste. The string can contain text and any combination of the HTML tags described in HTML Elements.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Standards information

There are no standards that apply here.

Remarks

This method might alter the HTML text to make it fit the given text range. For example, pasting 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, paste only well-formed HTML text that fits within the given text range.

This method is accessible at run time. If elements are removed at run time, before the closing tag is parsed, areas of the document might not render.

This feature might not be available on non-Microsoft Win32 platforms.

Examples

This example uses the pasteHTML method to replace the current selection with a new paragraph.


<script>
  var sel = document.selection;

  if (sel!=null) {
    var rng = sel.createRange();

    if (rng!=null) {
      rng.pasteHTML("<p><strong>Selection has been replaced.</strong></p>");
    }
  }
</script>

See also

TextRange

 

 

Anzeigen:
© 2014 Microsoft. Alle Rechte vorbehalten.