JavaScript абсолютный путь

location.pathname //gives you the local part of the url.

var filename = location.pathname.match(/[^\/]+$/)[0]
//The above gives you only the very last part. 
//For example, if you are on 
//http://somedomain/somefolder/filename.html, it will give you filename.html

//if you inspect the window.location object you will see

hash:       
host:       stackoverflow.com
hostname:   stackoverflow.com
href:       http://stackoverflow.com/questions/8401879/get-absolute-path-in-javascript
pathname:   /questions/8401879/get-absolute-path-in-javascript
port:       
protocol:   http:
search:     
Vast Vendace