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
本文介绍JavaScript中如何使用window.location.href获取当前页面的完整URL路径,以及通过location.hash属性来获取URL中的锚点部分。
1333

被折叠的 条评论
为什么被折叠?



