Gravatar for chris.williams@readwatchcreate.com

Question by chris williams, Oct 25, 2017 11:50 AM

For the coveo search box can you use a ? for the query string instead of a #

When using the coveo search box it produces query strings with # in them but standard query strings are “?” is there a way to change it so we can have the proper “?”

Eg. mysite.com/SearchResults#q=test but we want mysite.com/SearchResults?q=test

2 Replies
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Oct 25, 2017 12:01 PM

Coveo JavaScript Search Framework is a client side application working with AJAX to update the page on a user action instead of reloading it.

When updating the query string part (?) of the URL, the browser automatically reloads the page and the query string is sent to the server. This behavior can be disabled in recent browsers but not in older browsers.

However, when updating the hash (#) part of the URL, the browser do not reloads and the hash can be managed using JavaScript code.

To ensure the history functionality (back/forward) works for all the supported browsers, we have to use this method to store the search interface state. This cannot be changed.

Gravatar for mlaporte@coveo.com

Comment by Martin Laporte, Oct 25, 2017 12:11 PM

Note that it is possible to add some custom JS that would grab the ? part and initialize the query with it, the first time the page is loaded. But afterwards the query would still be stored in the hash part, and the ? would be ignored.

Gravatar for sbelzile@coveo.com

Answer by Sébastien Belzile, Oct 25, 2017 12:38 PM

Although it is not an ideal solution, you can also disable the functionality by setting the option `enableHistory` to false.

Ask a question