Created
March 22, 2021 10:52
-
-
Save webarthur/1250a697f341f937e01e1032b2d8f219 to your computer and use it in GitHub Desktop.
Função para ler os parâmetros da URL em JavaScript
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
| // from https://blog.devarthur.com/javascript/como-ler-os-parametros-da-url-em-javascript/ | |
| function getQueryParams (name, query) { | |
| var query = location.search.slice(1) | |
| var partes = query.split('&') | |
| var data = {} | |
| partes.forEach(function (parte) { | |
| var chaveValor = parte.split('=') | |
| data[chaveValor[0]] = chaveValor[1] | |
| }) | |
| return data | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment