当前位置: 代码迷 >> JavaScript >> 怎么获取当前网址的定位锚值
  详细解决方案

怎么获取当前网址的定位锚值

热度:180   发布时间:2012-02-17 17:50:42.0
如何获取当前网址的定位锚值?
如何获取当前网址的定位锚值?
如,当前网址:http://www.xxx.com/xx.htm#test
如何通过javascript或其他手段得到定位锚值   test   ???

------解决方案--------------------
var url = 'http://www.xxx.com/xx.htm#test ';
alert(url.substr(url.indexOf( '# ') + 1));
------解决方案--------------------
var h = document.location.hash;
if(h!= " ") h = h.substr(1,h.length-1);
alert(h);
------解决方案--------------------
document.location.hash.subString(1)
  相关解决方案