Rewrite url ala Google Instant?

2019-08-31 02:32发布

问题:

I have a e-commerce website built in Ajax and Js, when the user type a search keyword the list is pulled via ajax but the browser url, in my case doesn't change, so if the user reaload or simply bookmarks the address he 'll have to start form scratch loosing the keywords input.

i noticed Google instead rewrites the url with the complete query, no hashtag or complex workaround...apparently

how can i achieve that? consider i have complete control on my server so i can set my apache in any way i want.

thanks!!

回答1:

I'm not sure what browser you're using, but I get all the search terms after a hashtag in Chrome (e.g., http://www.google.com/#sclient=psy&hl=en&q=test+test+sibilance&aq=3&...). I don't think what you think is occurring is actually happening. It could be done on Chrome and other HTML5 browsers using history.pushState(), but I don't see Google Instant using that method.



回答2:

See this question, almost the same except they used Facebook as a example.

  • How does facebook rewrite the source URL of a page in the browser address bar?


回答3:

If you watch the URL in Google Instant, it doesn't change until you hit "Search" or pause for a set period of time (2 seconds, i think).

After this delay, Google refreshes the page with those search queries.



回答4:

Then it is not instant. Without reloading the page you can only change the fragment identifier in the URL.



回答5:

My experience is, that after you changed the search, the Google URL is no longer "correct", i.e. it does not represent the latest query.