If you are on http://www.cnn.com/2012/11/09/opinion/brown-pakistan-malala/index.html can you get Jquery to grab the index.html?
or if you a
function getCurentFileName(){
var pagePathName= window.location.pathname;
return pagePathName.substring(pagePathName.lastIndexOf("/") + 1);
}
No need for jQuery. This will give you the last segment of the URL path (the bit after the last slash):
var href = document.location.href;
var lastPathSegment = href.substr(href.lastIndexOf('/') + 1);
location.pathname.split('/').slice(-1)[0]
Although not JQuery, you can access it using the following:
document.location.href.match(/[^\/]+$/)[0]
or
document.location.pathname.match(/[^\/]+$/)[0] in case of unneeded anchors/hash tags (#).