具有当前查询的URL

时间:2012-08-12 18:59:58

标签: ajax url history permalinks

我有一个AJAX Web应用程序,我希望有一个URL来反映当前查询的内容,以便拥有“永久链接”。例如,用户在搜索输入中输入“foobar”作为查询,然后网址栏中的http://example/search/更新为http://example/search/?foobar

尝试使用index.html实现此目的时:

<script>
query = "foobar";
window.location.search = query;
</script>

首先,这奇怪地将浏览器发送到无限循环中。我错过了什么?

1 个答案:

答案 0 :(得分:0)

更改window.location会使浏览器重新加载该页面。