location.href 与 location.hash
this.hash 获取或设置标签值(jquery) (2015-03-03 15:34:13) 转载 ▼ 标签: this.hash jquery 使用出处: this.hash含义: location是javascript里边管理地址栏的内置对象,比如location.href就管理页面的url,用location.href=url就可以直接将页面重定向url。而location.hash则可以用来获取或设置页面的标签值,也就是锚链接的值。比如 http://domain/#admin 的location.hash="#admin"。 this.hash:获取当前链接的标签值: location.hash 综:window. location.href 表示 重定向 ,后面跟着的是完整的 url地址 ,与其相似的还有window. location.hash , 下面来比较window.location.href和window.loc ai ton.hash的区别。 (1) window.location.href 得到和使用的是完整的url,比如window.location.href="w ww.baidu.com ”表示的是重新定向,页面跳转 到新的页面。也可以通过window.location.href得到a标签的完整的href,比如<a href="#book"