Last active
September 6, 2017 06:25
-
-
Save guoshuai93/69862c1e9c1316fe5403c9c849364aee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. location的search操作——解析url字符串,返回包含所有参数的一个对象 | |
function getSearchObj(){ | |
var qs = location.search.length>0 ? location.search.substr(1):'', | |
args = {}, | |
items = qs.length>0 ? qs.split('&'):[], | |
item = null,name = null,value = null,i = 0,len = items.length; | |
for(i = 0;i < len; i++){ | |
item = items[i].split('='); | |
name = decodeURIComponent(item[0]); | |
value = decodeURIComponent(item[1]); | |
if(name.length){ | |
args[name] = value; | |
} | |
} | |
return args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment