Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Получение в jquery get-параметра с url страницы
// получаем URL параметры
// var allVars = $.getUrlVars();
// получаем значение параметра по его имени
// var byName = $.getUrlVar('name');
getUrlVars: function(){
var vars = [], hash;
var hashes = window.location.href.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;
getUrlVar: function(name){
return $.getUrlVars()[name];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment