1function getPathVariable(variable) {
2 var path = location.pathname;
3
4 // just for the demo, lets pretend the path is this...
5 path = '/images/awesome.jpg/page/about';
6 // ^-- take this line out for your own version.
7
8 var parts = path.substr(1).split('/'), value;
9
10 while(parts.length) {
11 if (parts.shift() === variable) value = parts.shift();
12 else parts.shift();
13 }
14
15 return value;
16}
17
18console.log(getPathVariable('page'));