window.location.hash常用方法
2014-02-11 14:04
155 查看
window.location.href是在js中经常见到的获取url链接的方式
而我们在一些url中却看到过类似的地址
http://www.abc.com/a/index.html#m2
其中的#m2 就是location.hash
loation.hash常与锚点联系起来使用
例如:
当点击 测试 按钮时,实现页面位置的改变
location.hash通过与iframe的结合 还能巧妙的解决js代理完全跨域的问题
虽然有些麻烦,但是却可以解决js完全跨域的问题
详见:利用iframe和location.hash实现跨域
而我们在一些url中却看到过类似的地址
http://www.abc.com/a/index.html#m2
其中的#m2 就是location.hash
loation.hash常与锚点联系起来使用
例如:
<head> <script> function getAnchor(anchor_name) { window.location.hash=anchor_name; } </script> </head>
<body> <a href="javascript:getAnchor('test');">点我测试</a> <div style="height:2000px">test</div> <a name="test">destination</a> </body>
当点击 测试 按钮时,实现页面位置的改变
location.hash通过与iframe的结合 还能巧妙的解决js代理完全跨域的问题
虽然有些麻烦,但是却可以解决js完全跨域的问题
详见:利用iframe和location.hash实现跨域
相关文章推荐
- Window、Document、Location、History对象的常用属性和方法
- js:window、location对象的常用属性和方法的应用
- window.location.hash在firefox下中文自动转码为UTF-8问题
- JS教程:window.location使用方法的区别
- window.location.href和window.location.hash的区别
- window.location不跳转的问题解决方法
- window.location方法
- window.location 的常用属性(获取当前页面的url)
- GPS开发常用方法 和用Criteria确定android location providerGPS开发常用方法
- 利用pushState, popState和location.hash等方法自己实现一个小型路由
- window对象的常用方法和作用
- Window对象的常用方法中带有提示信息、确定和取消按钮的对话框
- window.location.hash属性介绍
- Window.location.href以post方式传递参数的方法
- HTML、js:如何利用Location对象的常用属性和方法重新加载、刷新页面
- android window.requestWindowFeature()常用方法
- window.location方法
- window.location.hash属性介绍
- 【js与jquery】window.location.hash属性介绍
- javascript中的window.location.search方法