This code will show only the last part of any URL
URL GIVEN : www.codehaven.co.uk/firstpart/secondpart/themainimage.jpg
URL OUTPUT: themainimage.jpg
function multiply(x) {
var url = x;
var array = url.split('/');
thetext = array[array.length-1];
var thetextshort = thetext.substring(thetext.lastIndexOf("/") + 1, url.length);
return thetextshort;
}
alert(multiply("www.codehaven.co.uk/firstpart/secondpart/themainimage.jpg"));












