工作中封装了一些通用的公共方法,最常见的就属在url上拿参数了
现在用的是 getUrlParam2 方法
location.href 整个url地址
location.protocol 获取协议
location.pathname 获取地址
location.search 获取?后面的参数
location.hash 获取哈希
如:
http://www.baidu.com/class.html?aa=1&bb==2#id=123
location.href http://www.baidu.com/class.html?aa=1&bb==2#id=123
location.host www.baidu.com
location.protocol http://
location.pathname /class.htm
location.search ?aa=1&bb==2
location.hash #id=123
原文:https://www.cnblogs.com/Richard-M/p/10373711.html