js中:var url = window.location.href;//获取当前页的完整路径
var url_id = location.hash.substring(1)//通过 location.hash 属性得到 URL 中的锚:
参考http://www.5idev.com/p-javascript_location_hash.shtml
当前页面的 URL 是:http://www.5idev.com/p-javascript_history.shtml#back
<script type="text/javascript"> document.write(location.hash); </script>
运行该例子,输出:
#back