Click to See Complete Forum and Search --> : show current filename


mikecracker
11-19-2003, 11:13 AM
I want to make use of the filename of the document,
and thus need to use javascript to retrieve the filename.

However I tried "location" but it gives me the full URL of the current location, not the filename of it.

for example:
http://www.server.com/directory/filename.html
I just need to retrieve the part "filename.html"
what should I do?

any javascript codes can do that for me?

fredmv
11-19-2003, 11:25 AM
<script type="text/javascript">
//<![CDATA[
var url = 'http://www.server.com/directory/filename.html';
alert((url.substring( url.lastIndexOf('/') + 1), url.length));
//]]>
</script>