Javascript hash параметри
0
- 05.02.2012 (Неделя)
function getUrlHashParams() {
var hashParams = {};
var e,
a = /\+/g,
r = /([^&;=]+)=?([^&;]*)/g,
d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
q = window.location.hash.substring(1);
while (e = r.exec(q))
hashParams[d(e[1])] = d(e[2]);
return hashParams;
}
Малка javascript функция която взима hash параметрите от url адреса и ги "връща" като обект.
Примерно: URL: http://example.com/#pg=1&sort-gsm=asc
Object { pg="1", sort-gsm="asc"} 