Javascript, get segment.

ITsolutionWizard
ITsolutionWizard used Ask the Experts™
on
http://localhost:3835/Home/Hello

In javascript, how to get Hello?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Consultant & Challenge Subduer
Top Expert 2009
Commented:
I'd do it this way:
var segments = location.pathname.split(/\//); // the first item in the array will be an empty string
console.log(segments[2]);
console.log(segments[segments.length-1]);

Open in new window

https://developer.mozilla.org/en-US/docs/Web/API/Location

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial