当前位置: 移动技术网 > IT编程>开发语言>JavaScript > js获取地址栏中的数据

js获取地址栏中的数据

2018年10月24日  | 移动技术网IT编程  | 我要评论

window.location.href:设置或获取整个 url 为字符串
window.location.pathname:设置或获取对象指定的文件名或路径
window.location.search:设置或获取 href 属性中跟在问号后面的部分
要获取变量的值可以试试:
var urlparam= window.location.search;
var loc = urlparam.substring(urlparam.lastindexof('=')+1, urlparam.length);
如果是多个参数可以分布切割,得到多个键值对。
参考文章链接:https://blog.csdn.net/gotofind/article/details/78961694

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网