有关window.location.hash
来源:互联网 发布:java 二分法查找 编辑:程序博客网 时间:2024/06/07 09:33
虽然已经出来好久了,但是之前没有好好看…所以又忘了…最近真是发现自己的浅薄了(捂脸)
参考:http://www.cnblogs.com/yeer/archive/2013/01/21/2869827.html
还是想自己捋一遍
1.什么是location.hash
在url中出现 #… 井(#)号就是hash,如果输入window.location.hash,那么出现的就是#……(井号和他后面的内容)。井号后面的东西是页面的location,是用来索引页面的某段内容的,可以索引到锚点或者id,像<a name="flag1'></a>和<div id="flag1"></div>。
2.有什么用
location.hash是对于浏览器的指示,而不是服务器的。在http请求中不会有井号及其后面跟的内容。在改变location.hash的值后,浏览器会建立一个访问历史记录,这样用户可以回退到之前的位置(IE6,7并没有),并且页面滚动到相对应的位置,并不会发送http请求。
这种方式对于ajax很友善。我们知道ajax插入页面的数据不能使页面重载,因此不能回退到之前的版本(有了location.hash之后也不能> <),并且ajax加载成的数据不能被搜索引擎索引到。
1.可以创建历史,便于回到之前的定位但是不重载页面
2.便于引擎搜索ajax创建的动态数据
3.可读可写,方便定位
3.padding…
H5对location.hash新增了onhashchange事件,当hash值变化的时候触发该事件。
如果url中要请求带#号的内容,那么这个井号要进行转义(%23)再使用。因为如果不转义,浏览器就认为是hash而不会加入请求。
0 0
- 有关window.location.hash
- window.location.hash解析
- window.location.hash解析
- window.location.hash详解
- window.location.hash详解
- window.location.hash
- window.location.hash 使用说明
- window.location.hash
- window.location.hash 使用说明
- window.location.hash
- window.location.hash 使用说明
- window.location.hash属性介绍
- AJAX Navigation (window.location.hash)
- window.location.hash属性介绍
- window.location.hash使用总结
- window.location.hash属性介绍
- window.location.hash属性介绍
- window.location.hash常用方法
- tomcat6目录结构
- python 包的创建与使用
- solver参数说明
- Duplicate entry 和 Batch update
- 简析 cocos2d-x Android 调用启动过程
- 有关window.location.hash
- date java 时间相关
- android 全局变量的使用
- Android 最火的快速开发框架AndroidAnnotations使用详解
- MAC如何把项目放到Github上
- 第六次上机作业
- java变量及其作用域和调用方式
- redis主从模式
- AFNetworking 3.0迁移指南