Combine indexOf and substring methods to get the anchor part of a url
<html> <head> <title>Splitting a string into substrings</title> <script type="text/javascript" > var url = "http://www.a.com/j#ch_3"; var hash = url.indexOf("#"); var anchor = url.substring(hash + 1, url.length); document.write(anchor); </script> </head> <body> </body> </html>