0

我有一个 AJAX Web 应用程序,我想在其中使用 URL 来反映当前查询是什么,以便获得“永久链接”。例如,用户在搜索输入中输入“foobar”作为查询,然后http://example/search/在 URL 栏中更新为http://example/search/?foobar.

当尝试使用 index.html 实现这一点时:

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

首先,这奇怪地使浏览器陷入无限循环。我错过了什么?

4

1 回答 1

0

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

于 2013-01-14T08:23:09.970 回答