Paste HTML into a text range : Text Range : DOM Node JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » DOM Node » Text Range »

 

Paste HTML into a text range

















This example uses Internet Explorer ranges and will only work on Internet Explorer
<html>
    <head>
        <title>IE Range Example</title>
        <script type="text/javascript">
            function useRanges() {
                var oRange = document.body.createTextRange();
                var oP1 = document.getElementById("p1");
                oRange.findText("Hello");
                oRange.pasteHTML("<em>Java2s.com</em>");
            }
        </script>
    </head>
    <body><p id="p1"><b>Hello</b> World</p>
        <input type="button" value="Use Ranges" onclick="useRanges()" />  
    </body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo DOM Node
» Text Range