js中的location的href和pathname,search
来源:互联网 发布:天池大数据竞赛时间 编辑:程序博客网 时间:2024/05/16 06:47
js中的location的href和pathname,search
在我们使用浏览器中访问一个url,HTTP GET获取到一个资源后。我们可以查看浏览器的location对象。
比如,我们search一下,在浏览器中会出现下面的url:
https://www.bing.com/search?q=location.href+location.pathname&go=%E6%8F%90%E4%BA%A4&qs=n&form=QBLH&pq=location.href+location.pathname&sc=0-14&sp=-1&sk=&ghc=1&cvid=be38977d2c4d483ba842e8019853315f
- 使用window.location.href
得到的结果时浏览器地址栏中的完整地址串:
“https://www.bing.com/search?q=location.href+location.pathname&go=%E6%8F%90%…ion.pathname&sc=0-14&sp=-1&sk=&ghc=1&cvid=be38977d2c4d483ba842e8019853315f”
- window.location.pathname
得到URL的路径部分(就是请求映射的地址)
“/search”
如果我们修改pathname,则浏览器中的地址栏url的pathname部分就会改变,并触发新的http get操作。但是后面接着的参数长串依然存在。
- window.location.search
得到的是:
“?q=location.href+location.pathname&go=%E6%8F%90%E4%BA%A4&qs=n&form=QBLH&pq=location.href+location.pathname&sc=0-14&sp=-1&sk=&ghc=1&cvid=be38977d2c4d483ba842e8019853315f”
其他:
- window.location.host
“www.bing.com”
- window.location.hostname
“www.bing.com”
- window.location.port
“”
==== 说明: URL 的端口部分
如果采用默认的80端口(update:即使添加了:80),那么返回值并不是默认的80而是空字符
本例返回值:”“
- window.location.hash
如果使用了锚点,比如对于这样一个URL
http://localhost:8080/search?ver=1.0&id=6#herepointer
锚点 返回值:#herepointer
- js中的location的href和pathname,search
- location.href/location.search/location.pathname区别及用法
- location.href/location.search/location.pathname区别及用法
- javascript 中的location.pathname
- javascript 中的location.pathname
- javascript 中的location.pathname
- location.href和location.search区别
- 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法
- 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- js中window.location.href,location.href,parent.location.href,top.location.href的用法
- 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法 .
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- Java读取UTF-8格式文件第一行出现乱码——问号“?”及解决 And Java读带有BOM的UTF-8文件乱码原因及解决方法
- Heap 堆
- 吸引女性玩家来玩游戏的十八个关键要素
- Collabtive系统XSS攻击实验
- android 通过bitmapfactory得到图片真实像素的方法,以及没有得到真实像素的原因
- js中的location的href和pathname,search
- Java继承学习小结
- windows 下 解决 QT 与 mysql 数据库 驱动问题的本质
- windows在ISR中不能睡眠的原因
- Android Studio实现代码混淆
- 浅谈sqlserver2008备份与还原的方法一
- 天声人語 20150722
- Html学习笔记4
- 循环单链表实现约瑟夫环