topical media & game development

talk show tell print

professional-javascript-10-IERangeExample4.htm / htm



  <html>
      <head>
          <title>IE Range Example</title>
          <script type="text/javascript">
              //This example shows what happens when you try to use
              //pasteHTML() while HTML code is selected.
              function useRanges() {
                  var oRange = document.body.createTextRange();
                  var oP1 = document.getElementById("p1");
                  oRange.moveToElementText(oP1);
                  oRange.pasteHTML("<p><em>Howdy</em> World</p>");
                  alert(document.body.innerHTML);
              }
          </script>
      </head>
      <body><p id="p1"><b>Hello</b> World</p>
          <input type="button" value="Use Ranges" onclick="useRanges()" />      
          <p><strong>Note:</strong> This example uses Internet Explorer ranges and will only work on Internet Explorer.</p>
    
      </body>
  </html>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.