Created
February 15, 2017 17:16
-
-
Save neopablix/b774a132408c4eebf3c1d15456b69b87 to your computer and use it in GitHub Desktop.
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 replaceQueryParam(param, newval, search) { | |
var regex = new RegExp("([?;&])" + param + "[^&;]*[;&]?"); | |
var query = search.replace(regex, "$1").replace(/&$/, ''); | |
return (query.length > 2 ? query + "&" : "?") + (newval ? param + "=" + newval : ''); | |
} | |
var str = window.location.search; | |
str = replaceQueryParam('lat', gValue.latitude, str); | |
str = replaceQueryParam('lng', gValue.longitude, str); | |
window.location = window.location.pathname + str; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment