Created
March 29, 2015 14:25
-
-
Save naosim/84d4533e2afe8a3eeaf1 to your computer and use it in GitHub Desktop.
URLからQueryを取得する
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
| var getQuery = function() { | |
| var result = {}; | |
| if(location.href.indexOf('?') == -1) return result; | |
| var lastIndex = location.href.indexOf('#') != -1 ? location.href.indexOf('#') : location.href.length; | |
| var kvs = location.href.slice(location.href.indexOf('?') + 1, lastIndex).split('&'); | |
| for(var i = 0; i < kvs.length; i++) { | |
| var kv = kvs[i].split('='); | |
| result[kv[0]] = kv[1]; | |
| } | |
| return result; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment