Created
May 7, 2021 11:21
-
-
Save aalfiann/8475807281609fe55ab8be9336aca210 to your computer and use it in GitHub Desktop.
Get URL Parameter
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 getUrlParam(url) { | |
if (url) { | |
var query = url.split('?'); | |
if (query[1]) { | |
var data = {}; | |
var queries = query[1].split('&'); | |
for (var i = 0; i < queries.length; i++) { | |
var item = queries[i].split('='); | |
data[item[0]] = decodeURIComponent(item[1]); | |
} | |
return data; | |
} | |
} | |
return ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment