I request the javascript guru masters again!
Okay this is probably simple, blowing my mind atm.
Example: http://example.com/page.php
var path = location.pathname;
Returns: /page.php
I would like it to not include the first / so it would return page.php
Thank you guru masters!
You just need to use one of the several substring functions.
var path = location.pathname.substr(1);
Update:
substr is now a deprecated method, so you should use slice instead.
var path = location.pathname.slice(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