<html> <body> <script language="JavaScript"> function function1() { var myNode = document.body.createTextRange(); myNode.text = 'text for new text range'; } </script> <button onclick="function1();">Create text range</button> </body> </html>