I'm trying to figure out how to split a url variable... I tried these two ways, with an alert to see my result, but I'm not getting anything. Suggestions?
Code:
function() { myURL = "http://www.test.com/folder1/folder2/someone" var partsA = myURL.split("//"); var parts = partsA[1].split("/"); alert(parts[2]); }
Code:
function() { myURL = "http://www.test.com/folder1/folder2/someone" var parts = myURL.split('/'); var result = parts[parts.length-2] + '/' + parts[parts.length-1]; alert(result); }
Comment