Hi Friends Can you please tell me how to get only filename form the current page URL? For example: http://www.web.com/abc/xyz/index.php?a=1&b=2; If you open the above url, then I need to display only index.php. Thanks in advance.
var url = 'http://www.web.com/abc/xyz/index.php?a=1&b=2'; var lastSlash = url.lastIndexOf("/"); var firstQuestionMark = url.indexOf("?"); if(firstQuestionMark == -1) { firstQuestionMark = url.length; } var fileName = url.substring(lastSlash + 1, firstQuestionMark); alert(fileName);