Looking for a way to parse key pairs out of the hash/fragment of a URL into an object/associative array with JavaScript/JQuery
|
Check out: jQuery BBQ jQuery BBQ is designed for parsing things from the url (query string or fragment), and goes a bit farther to simplify fragment-based history. This is the jQuery plugin Yarin was looking for before he put together a pure js solution. Specifically, the deparam.fragment() function does the job. Have a look! (The support site I'm working on uses an asynchronous search, and because BBQ makes it trivial to tuck entire objects into the fragment I use it to 'persist' my search parameters. This gives my users history states for their searches, and also allows them to bookmark useful searches. Best of all, when QA finds a search defect they can link straight to the problematic results!) |
||||
Here it is, modified from this query string parser:
No JQuery/plug-in required Update: I'm now recommending the jQuery BBQ plugin as per Hovis's answer. It covers all hash parsing issues. |
|||||
|
I am using jQuery URL Parser library. |
|||||
|
My answer to this question should do what you're looking for:
|
|||
|