Created
September 15, 2011 17:06
-
-
Save zachpendleton/1219832 to your computer and use it in GitHub Desktop.
get param from URL (rails friendly)
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
function getParam(name){ | |
var pathRegex = new RegExp(name + '\/([^\/]+)'), | |
searchRegex = new RegExp(name + '=([^&]+)'), | |
match; | |
match = (window.location.pathname.match(pathRegex) || window.location.search.match(searchRegex)); | |
if (!match) return false; | |
return match[1]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment