0

My requirement is to parse query string, get value of a key.. modify it and add it back in query string.

I am retreving querystring in a variable.

var a_href =  jQuery('#linkHere').attr('href');

lets say my value is something like this : a_href = "?position=1&archiveid=5000&columns=5&hash_ref="http://xxx.com"

Now I want to retrieve hash_ref value. Please note that hash_ref is a window.location value, now i need to update it to add window.location.hash value to hash_ref and assign it back to a_href variable.

How can we do this with jQuery?

TopCoder
  • 4,206
  • 19
  • 52
  • 64

1 Answers1

0

use this - http://blog.stevenlevithan.com/archives/parseuri

var theValue = parseUri(uri).queryKey.a_href

there is also a jQuery pluging (http://plugins.jquery.com/project/url_parser) based on this function.

I am also assuming that the url in your query string is actually url encoded so you may need to decode it, I can't remember off the top of my head

Adam Straughan
  • 2,766
  • 3
  • 20
  • 27