Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Say I have this main page /my-site/all-my-bath-soaps which lists all my products.

It has a search filter text box that uses javascript to filter the products they want to see on that page (the URL doesn't change as they filter).

Now from many other parts of the site I want to navigate to this products-page and see specific products. E.g.

<a href="/my-site/all-my-bath-soaps?filter='Nivea-Soap'">

will go to /all-my-bath-soaps and apply javascript filtering to see just that product and hide all dom nodes for the other products.

The problem is if the user changes the text in the filter from 'Nivea-Soap' to 'Lynx' the javascript will work fine and show the new products but the URL stays at ?filter='Nivea-Soap'.

Is there anything I can do about this? Of course, I don't want to reload the page with a new query string every time they change the search criteria. Somehow it'd be great to move the ?filter=... criteria into POST data instead - but how can I do this with a link I don't know...

share|improve this question
    
Why do you really need that? Is it for SEO when user will share the page? Or just in a pure cosmetic way? –  j0k Dec 3 '12 at 14:19
    
A workaround might be to generate a permalink when you perform your JavaScript search. –  w3d Dec 3 '12 at 14:29
    
@j0k - yes partly for SEO, partly for sharing and partly incase they want to save that search into favouries. –  nchaud Dec 4 '12 at 17:32

1 Answer 1

As far as I know you cannot change the URL path with javascript; this is primarily for security reasons. However you can change the hash. It is probably possible to change your javascript to work with #Nivea-Soap instead of ?filter=Nivea-Soap, although that would be a coding issue outside the scope of this stackexchange.

Note however that this solution would be even worse for SEO than your current solution. If you would like people to be able to find your products directly from search results you should consider giving unique URLs to the product pages even if it means reloading the page for them, though you could continue to use javascript solutions for search result filtering.

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.