Get URL location pathname -


let's have dummy website url: http://company.com/something.

i need grab path: /something , use switch case redirect new url using javascript.

can please guide me?

var url; var url_param = location.pathname;  switch(url_param) {      case "/how-to-do-this":           url = '/your-new-destination/';       default:           url: '/thankyou/';  console.log("your new url is: " + url); 

thanks.

i assume you're using javascript

var url;  switch(window.location.pathname) {      case "/how-to-do-this":           url = '/your-new-destination/';       default:           url= '/thankyou/'; } console.log("your new url is: " + url); 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -