So let's say there's a URL <a href="http://example.com/index.html/hello/hi" rel="nofollow">http://example.com/index.html/hello/hi</a> where "hello" and "hi" are parameters.
Your subject is a little bit vague. However, I thought I'd made an example of possibilities. <a href="http://jsfiddle.net/tive/LjbPq/" rel="nofollow">http://jsfiddle.net/tive/LjbPq/</a>
The idea is to split the URL for each character /, in whatever way you received it.
var parts = document.URL.split("/");
Since split() returns an array (zero based), you need to distract 1 from the total length to get the last index.
var lastPart = parts[parts.length - 1];
Run this in a for loop, and you should get the idea as occurring in the example.<ul><li><a href="http://www.w3schools.com/jsref/prop_doc_url.asp" rel="nofollow">documentation on document.URL</a> to retreive the complete URL</li> <li><a href="http://www.w3schools.com/jsref/obj_location.asp" rel="nofollow">documentation on window.location</a> to use properties of a url (protocol, href, pathname, ...)</li> </ul>Answer2:
this could work...
var secondvar = window.location.href.split('/')[window.location.href.split('/').length]; var firstvar = window.location.href.split('/')[window.location.href.split('/').length-1];