Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question
possible duplicate of stackoverflow.com/questions/647259/javascript-query-string – Harish Mar 23 '11 at 11:46

1 Answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.