Created
October 15, 2015 07:10
-
-
Save kehr/a8e054103f4ee289e108 to your computer and use it in GitHub Desktop.
Get the search key of url
This file contains 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
var getSearchKey = function(key){ | |
if (!location.search) return null; | |
var list = location.search.split("?")[1].split("&"); | |
for (var i=0; i < list.length; ++i){ | |
if (!list[i]) continue; | |
var dict = list[i].split("="); | |
if (key == dict[0]){ | |
return dict[1] | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment