Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
134
rated 0 times [  138] [ 4]  / answers: 1 / hits: 73397  / 13 Years ago, tue, december 13, 2011, 12:00:00

I was wondering if it would be possible to get the page name from the address bar using jquery or javascript. I know this can be done using PHP but don't really want to as it is only a html website.



I.e. if the address is www.mywebsite.com/hello.htm how do I get the hello.htm part out of the address.



Thanks for any help you can provide.


More From » jquery

 Answers
35

https://developer.mozilla.org/en/DOM/window.location



alert(location.pathname)


If you don't want the leading slash, you can strip it out.



location.pathname.substring(1)

[#88571] Monday, December 12, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
deonkalvinw

Total Points: 409
Total Questions: 96
Total Answers: 89

Location: Saint Pierre and Miquelon
Member since Sun, Nov 27, 2022
2 Years ago
deonkalvinw questions
Sun, Feb 6, 22, 00:00, 2 Years ago
Tue, Dec 28, 21, 00:00, 2 Years ago
Sun, Aug 22, 21, 00:00, 3 Years ago
Sun, Mar 7, 21, 00:00, 3 Years ago
;