How to use javascript to get the following url - the value of id?
URL: http://www.url/id/2721/John
I would get the following values:
2721 and John
Corbin
33.6k7 gold badges74 silver badges79 bronze badges
asked May 7, 2012 at 21:24
JohnMalcom
8614 gold badges16 silver badges28 bronze badges
-
6out of curiosity, what have you tried?MilkyWayJoe– MilkyWayJoe2012年05月07日 21:26:59 +00:00Commented May 7, 2012 at 21:26
-
Show us what you've tried and why/where you're hung up. Don't just expect us to do the work for you.James Johnson– James Johnson2012年05月07日 21:30:11 +00:00Commented May 7, 2012 at 21:30
-
Possible duplicate? stackoverflow.com/questions/6168260/how-to-parse-a-url stackoverflow.com/questions/4140324/parse-url-with-javascript stackoverflow.com/questions/7840306/… stackoverflow.com/questions/901115/…Jack– Jack2012年05月07日 21:32:53 +00:00Commented May 7, 2012 at 21:32
-
css-tricks.com/snippets/javascript/…kmb64– kmb642012年05月07日 21:34:12 +00:00Commented May 7, 2012 at 21:34
2 Answers 2
Use .split("/") to separate the URL into pieces, then read the values.
answered May 7, 2012 at 21:27
Niet the Dark Absol
326k86 gold badges480 silver badges604 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js