Skip to content

Instantly share code, notes, and snippets.

@adam
Created October 29, 2010 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adam/652991 to your computer and use it in GitHub Desktop.
Save adam/652991 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
if (window.location.search.length > 0) {
// crunch the window.location.search to pull the query value
var parsedQuery = jQuery.map(window.location.search.replace('?', '').split("&"), function(val, i){return [val.split('=')[0], val.split('=')[1]]});
var queryValue = parsedQuery[parsedQuery.indexOf('query') + 1].replace('+', ' ');
if (queryValue && queryValue != null && queryValue != '') {
$('.search form input[type=text]').val(queryValue);
$('.search form input[type=text]').attr('original_value', queryValue);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment