-2

How can I get Parameter values from url after # tag? for example, I have the url like this

1) index.html#page=home
2) index.html#page=topic?secid=1&catid=1

from above urls, i have to get parameter values of page, secid and catid.

Yeldar Kurmangaliyev
  • 33,467
  • 12
  • 59
  • 101
Mohan
  • 398
  • 7
  • 24

1 Answers1

2

To get all of the text, you can use window.location.hash, including the hash symbol. Here's some information about parsing query string parameters.

Community
  • 1
  • 1
Patrick Steadman
  • 728
  • 7
  • 11
  • `location.hash` is inconsistent across browsers. Better to parse `location.href`. – Alexander O'Mara Nov 20 '15 at 06:28
  • @AlexanderO'Mara: what browsers have trouble with location.hash? i've used it a lot without issues... – dandavis Nov 20 '15 at 06:34
  • 1
    If memory serves and nothing has changes recently, Mozilla browsers will automatically decode entities, but other browsers will not, leaving you with a string that may or may not be decoded. I'm not sure if there is a spec that defines the behavior one way or the other. Old IE also had trouble, especially IE6, but I don't remember all the details of that. – Alexander O'Mara Nov 20 '15 at 06:37