Use document.location.href to get the whole location, and then there's a number of ways you can go about getting just the documents name.
It depends on what you exactly want to get - if you want the extension included, then:
Code:
function returnDocument() {
var file_name = document.location.href;
var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
return file_name.substring(file_name.lastIndexOf("/")+1, end);
}
Or you could use split("/") etc... Like I say - there's a tonne of ways, and it also depends exactly on what you want.
Oh, the above gives you the document name with it's extension, and also takes into account if it has a search string appended on the end.