Skip to content

Instantly share code, notes, and snippets.

Created July 27, 2016 14:41
  • Star 10 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Get Last Segment of a URL in Javascript
var pageURL = window.location.href;
var lastURLSegment = pageURL.substr(pageURL.lastIndexOf('/') + 1);
Copy link

mady143 commented Feb 28, 2019

for suppose in my url i am having like +,=,/,<,> like this then how can i get the last segment can you explain me

Thanks in advance
Happy codding....

Copy link

Thank you bro, this tutorial saved my time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment