Created
December 20, 2015 13:42
-
-
Save espl-saket/20836e4d8d3c8e0e8a5e to your computer and use it in GitHub Desktop.
Method to get the URL params using jQuery
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
var urlParamMap = {}; | |
(function () { | |
var urlParams = window.location.href.split("?"); | |
if (urlParams.length > 1) { | |
var paramArray = urlParams[1].split("?"); | |
for (var i = 0; i < paramArray.length; i++) { | |
var paramKeyValue = paramArray[i].split("="); | |
urlParamMap[paramKeyValue[0]] = paramKeyValue[1]; | |
} | |
} | |
})(); | |
$.getUrlParam = function (param) { | |
if (!urlParamMap) return; | |
if (!urlParamMap[param]) return; | |
return urlParamMap[param]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment