JS获取当前页码URL中信息
2016-03-21 13:31
134 查看
一、设置或获取对象指定的文件名或路径:
window.location.pathname
二、设置或获取整个 URL 为字符串:
window.location.href
三、设置或获取与 URL 关联的端口号码:
window.location.port
四、设置或获取 URL 的协议部分。
window.location.protocol
五、设置或获取 href 属性中在井号“#”后面的分段:
window.location.hash
六、设置或获取 location 或 URL 的 hostname 和 port 号码:
window.location.host
七、设置或获取 href 属性中跟在问号后面的部分。
window.location.search
八、获取变量的值(截取等号后面的部分)
var url = window.location.search;
// alert(url.length);
// alert(url.lastIndexOf('='));
var loc = url.substring(url.lastIndexOf('=')+1, url.length);
window.location.pathname
二、设置或获取整个 URL 为字符串:
window.location.href
三、设置或获取与 URL 关联的端口号码:
window.location.port
四、设置或获取 URL 的协议部分。
window.location.protocol
五、设置或获取 href 属性中在井号“#”后面的分段:
window.location.hash
六、设置或获取 location 或 URL 的 hostname 和 port 号码:
window.location.host
七、设置或获取 href 属性中跟在问号后面的部分。
window.location.search
八、获取变量的值(截取等号后面的部分)
var url = window.location.search;
// alert(url.length);
// alert(url.lastIndexOf('='));
var loc = url.substring(url.lastIndexOf('=')+1, url.length);
相关文章推荐
- [bzoj1826] [JSOI2010]缓存交换
- JSON 和 XML优缺点的比较
- 2016 JavaScript 技术栈展望
- [数据存储之五]JSON文件读取
- 如何将js中的值传到后台action中
- JS文件中引用另一个JS文件
- 《JS高程》对象&原型学习笔记
- JavaScript系列:正则表达式
- js 跨域访问
- JS实现数字千位符格式化方法
- js操作select
- 7、JSONArray的应用
- ExtJs中组件最好少使用ID属性(推荐更多使用Name属性)
- Map 转 JSON
- JSON 转Map
- .net json序列化组件Json.NET(Newtonsoft.Json)
- js函数的参数
- js获取对象的属性和方法总结
- js实现trim() JS去掉首尾空格 JS去掉两头空格
- 常用JS表单验证函数