Created
June 22, 2017 08:58
-
-
Save benmann/2e2f1b1236fe7eac682d22e5528a556a to your computer and use it in GitHub Desktop.
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
getParam: function (name, url) { | |
if (!url) url = location.href; | |
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); | |
var regexS = "[\\?&]" + name + "=([^&#]*)", | |
regex = new RegExp(regexS), | |
results = regex.exec(url); | |
return results === null ? null : results[1]; | |
} | |
// example.com?q=test => getParam("q") = "test" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment