Created
July 27, 2016 14:41
-
-
Save jserrao/40f7b18ea91f42af4687ab30ceaee004 to your computer and use it in GitHub Desktop.
Get Last Segment of a URL in Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pageURL = window.location.href; | |
var lastURLSegment = pageURL.substr(pageURL.lastIndexOf('/') + 1); | |
console.log(lastURLSegment); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you bro, this tutorial saved my time!