Last active
August 29, 2015 14:23
-
-
Save raphaelchaib/c40b8ff72d49c83b152c to your computer and use it in GitHub Desktop.
JavaScript: Get array of url params (jQuery)
This file contains hidden or 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
$.urlParam = function(name, url){ | |
var url = url || window.location.href; | |
var reg = new RegExp('[\?&]' + name + '=([^&#]*)', 'g'); | |
var results, returnResult = new Array(), i = 0; | |
while(results = reg.exec(url)) { | |
returnResult[i] = results; | |
i++; | |
} | |
if (returnResult==null){ | |
return null; | |
} | |
else{ | |
return returnResult || 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment