Skip to content

Instantly share code, notes, and snippets.

@koloda
Last active August 29, 2015 14:16
Show Gist options
  • Save koloda/b40d8ac6ae97ac3a0065 to your computer and use it in GitHub Desktop.
Save koloda/b40d8ac6ae97ac3a0065 to your computer and use it in GitHub Desktop.
(JS) Считывает GET переменные из URL страницы и возвращает их как ассоциативный массив.
function getUrlVars()
{
var vars = {}, hash;
var hashes = window.location.toString().slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars[hash[0]] = hash[1];
}
return vars;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment