Could we do:
```javascript
var val = $('#topnavigation-search-query', $(this)).val());
val = encodeURIComponent($.trim(val));
document.location = '/search#q=' + val;
```
?