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