-2

I have got a url by using

var url = window.location.href;
console.log(url);

This is the url

http://www.myproject.com/wp/?edit_project=797#step2=project

Now i want get the step2 from this url. Any clue how to get this only from the url.

user3747821
  • 21
  • 1
  • 8

2 Answers2

0

window.location.hash returns "#step2=project". And you need to parse it out(there is no restriction for the hash part of url).

John Hua
  • 1,400
  • 9
  • 15
-3

This will work:

var startIndex = url.indexOf("step2");

var step2 = url.substr(startIndex);