Answer the question
In order to leave comments, you need to log in
How to parse location.hash in such a way as to put it into an array (as a key=value pair) and output something like this: alert(data.value1)?
Hello dear) So, I have this:
urlHash=location.hash.slice(1);
alert(urlHash); // выводит param1=value1¶m2=value2
alert(urlHash.param1); // нужно чтобы выводило value1, так же и с другими параметрами
Answer the question
In order to leave comments, you need to log in
There is even no need for regular seasons with their powerful exec
var params = location.hash.slice(1).split('&'),
result = {};
for (var i = 0; i < params.length; i++) {
var _result = params[i].split('=');
result[_result[0]] = _result[1];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question