location的hash对象

来源:互联网 发布:mac 终端哪个好 编辑:程序博客网 时间:2024/06/06 17:39

location的hash对象,主要是设置或返回从井号 (#) 开始的 URL(锚),通过location.hash来调用,是一个可读可写的字符串

例如当前地址的url是:

http://write.blog.csdn.net/postedit?id=1&name=2#123_234_567

那么

location.hash="#123_234_567";

另:location.search是设置或返回从问号 (?) 开始的 URL(查询部分),也是一个可读可写的字符串,若是上面的url地址,那么

location.search="?id=1&name=2#123_234_567"



注:有关js的hash对象,这个和location的hash对象有本质的区别,js的hash对象有如json对象一样,都是键值对


原创粉丝点击