Is it possible that I can get the current page using javascript?
for example if I get to the home page of subpage, I will the the string name of index.php or if I go to the about page I can get the about.php.
I try this code :
window.location.pathname
but I got this in return in my subdomain.
/directory/new/index.php and /directory/new/about.php
Does anyone have an idea about my case? any help will be appreciated.
window.location.hrefortop.location.hrefYou will get “http://stackoverflow.com/questions/13678553/how-to-get-the-current-page-using-javascript” for this page.
`var url=window.location.href.split('/'); var name=url[url.length-1];`name is the index.php or about.php