This is an equivalent function to the method of C# Request.QueryString, in order to return the URL parameters derived
Last active
March 16, 2016 18:51
-
-
Save vinicius-stutz/40270751e28d04c06320 to your computer and use it in GitHub Desktop.
Query string via JavaScript
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
// Equivalent function to Request.QueryString (C#) to get the URL parameters | |
function queryString(key) { | |
var re = new RegExp('(?:\\?|&)' + key + '=(.*?)(?=&|$)', 'gi'); | |
var r = [], m; | |
while ((m = re.exec(document.location.search)) != null) r.push(m[1]); | |
return r; | |
} | |
// How to call | |
var id = queryString('id'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment