Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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'));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #seo #url #parameters
ADD COMMENT
Topic
Name
2+4 =