-2

For example, let's say http://www.google.com/Stack/overflow

In this above example, overflow is the last character. I need to fetch that overflow character

Please help me to achieve this

window.location.href
Francisco
  • 10,918
  • 6
  • 34
  • 45
Shyam
  • 5
  • 2

1 Answers1

2

Try this:

window.location.href.split('/').pop();

This splits the URL and returns the last element of that array using .pop().

31piy
  • 23,323
  • 6
  • 47
  • 67