1

Currently I am on this page:

www.mysite.com/page1/

Now I want to get the last portion from that URL which is page1

I am using the following but it's showing me full URL. I need only page1

var curPage = window.location;

How can I get this?

Shibbir Ahmed
  • 161
  • 2
  • 12

1 Answers1

2
var curPage = window.location.pathname;

See this URL for more info

How to extract the hostname portion of a URL in JavaScript

LiverpoolOwen
  • 806
  • 2
  • 10
  • 25