function searchToQuery(search) {
search = search || window.location.search;
var queryObj = {};
if (search.indexOf('?') == 0) {
search = search.substr(1);
}
var query = search.split('=')
for (var i = 0; i < query.length; i += 2) {
queryObj[query[i]] = query[++i]
}
return queryObj;
}
複製代碼