javascript seo url parameters

Solutions on MaxInterview for javascript seo url parameters by the best coders in the world

showing results for - "javascript seo url parameters"
Michel
07 Jan 2019
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'));