What I get from location.href
is like this:
http://stackoverflow.com/questions/ask
But I only want to get questions/ask
(no /
at the first character)
How to achieve this?
location.pathname.substr(1)
would that be.
The location
object has a pathname
property.
This will give you /questions/ask
and to remove the first character, use substring(1)
:
var path = location.pathname.substring(1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With