Gravatar for

Question by jschjolberg, May 13, 2014 5:40 PM

Can you pass a keyword search term in the query string using the JavaScript Search Framework?

Can I link to my search page with a keyword in the query string and have that load results when using the JavaScript Search Framework? Like this:

Is there a way for the initial search to use this keyword (q) in the query string?


1 Reply
Gravatar for

Answer by Gregory Laporte, May 13, 2014 5:43 PM


If you have history enabled on your SearchInterface, you can use the following:

The processing is done client side rather than server side, so you need to add the #.

Gravatar for

Comment by olamothe, May 14, 2014 11:00 AM

Just a small correction, the history is not on by default. You need to add this to your search interface

<div class='CoveoSearchInterface' data-enable-history='true'></div>

Gravatar for

Comment by jschjolberg, May 14, 2014 1:38 PM

Thanks - do you know if there is a trick to getting this to work when linking from another page? This does work when I am on the page and just add "#q=searchterm" to the end but when I link to the page with this in the query string it does not. I have data-enable-history set to true.

Gravatar for

Comment by Gregory Laporte, May 14, 2014 1:43 PM

It's not a query string parameter. You can craft a link and put the q= after the # instead of putting it directly after the searchpage.

Gravatar for

Comment by jschjolberg, May 14, 2014 3:26 PM

Thanks - I'll look into it.

Gravatar for

Comment by Alexandre Paré, May 15, 2014 3:33 PM

Can you give me the line where you get this error?

Gravatar for

Comment by jschjolberg, May 22, 2014 2:16 PM

I've resolved this - it was unrelated to Coveo. Sorry for the hassle!

Ask a question