Created
January 27, 2017 11:25
-
-
Save pawiromitchel/306005cb2c8b6d177c0c2ace5f862590 to your computer and use it in GitHub Desktop.
JS - get the parameter from the URI
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 getUriParam(name){ | |
if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search)) | |
return decodeURIComponent(name[1]); | |
} | |
// usage -> url: http://localhost/index.html?id=1 | |
var a = getUriParam('id'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment