<html> <body> <script language="JavaScript"> function function1() { var range = document.all.myP1.firstChild; var m = range.substringData(5, 10); alert(m); } </script> <p id="myP1">This is a sample text.</p> <input type="button" value='Extract data from 5 to 10' onclick="function1();"> </body> </html>