A small snippet of code I wrote a few minutes ago. I tried to find a function that would parse the URI so I can load the appropriate content via AJAX.. and well, after a few Google searches I found nothing. Maybe there are some better solutions, but here’s my small contribution.
function parseURI() {
// get the URI and remove the hash
var uri = window.location.hash.substring(1);
// parse the data
var elements = uri.split('&');
// the Object that will have the data
var data = new Object();
// do a for loop
for(i = 0; i < elements.length; i++) {
// split the element to item -> value format
var cur = elements[i].split('=');
// append the element to the list
data[cur[0]] = cur[1];
}
// return the result
return data;
}
Hey there I only wanted to stop by and say I enjoyed reading your blog!
Cool site, keep posting!