js获取地址栏中的数据

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

posted @ 2018-10-24 10:30  黄浩#  阅读(1674)  评论(0编辑  收藏  举报