Created
January 26, 2016 09:59
-
-
Save cubika/8556c1313e953a11ecac to your computer and use it in GitHub Desktop.
getQueryString
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
| function getQueryString(url, name) { | |
| var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'); | |
| var index = url.indexOf('?'); | |
| var r = url.substr(index).substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配 | |
| var context = ''; | |
| if (r != null) | |
| context = r[2]; | |
| reg = null; | |
| r = null; | |
| return context == null || context == '' || context == 'undefined' ? '' : context; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment