Answers for "javascript seo url parameters"

0

javascript seo url parameters

function getPathVariable(variable) {
  var path = location.pathname;

  // just for the demo, lets pretend the path is this...
  path = '/images/awesome.jpg/page/about';
  // ^-- take this line out for your own version.

  var parts = path.substr(1).split('/'), value;

  while(parts.length) {
    if (parts.shift() === variable) value = parts.shift();
    else parts.shift();
  }

  return value;
}

console.log(getPathVariable('page'));
Posted by: Guest on April-21-2020

Code answers related to "javascript seo url parameters"

Code answers related to "Javascript"

Browse Popular Code Answers by Language