If you only have the path in the URL, then you cannot get the filename from it - not using jQuery, not using any other client-side method. This is because only the server that sends this file knows what this file is. Specifically, in the web server configuration, there's a directive, which indicates what filename to search for if only the directory name is specified. For example, in apache this can be
DirectoryIndex index.html index.php home.htm
This tells the server that for requests with only a directory name the server will attempt to serve file index.html
from that directory; if it doesn't exist, then index.php
; if that also doesn't exist then home.htm
. If that one also doesn't exist, then the behaviour depends on other configuration options. Other web server software has similar configuration options.
Hence, when you send a request like http://www.yoursite.com/folder/ to a server, only that server will know what file is actually used.