我正在创建一个照片库,并希望能够更改查询字符串和标题时的照片浏览。
我所寻找的行为通常在一些连续/无限页面的实现中可以看到,当您向下滚动查询字符串时,页面编号(http://x.com?page=4)会不断增加,等等。这在理论上应该很简单,但是我想要一些在主流浏览器上是安全的东西。
我找到了 这个伟大的职位,并试图遵循 window.history.pushstate
的例子,但这似乎并不适合我。我不确定它是否理想,因为我并不真正关心修改浏览器历史记录。
我只是想能够提供书签的能力,目前浏览的照片,而不是重新加载页面的每一次照片被改变。
下面是修改查询字符串的无限页的示例: http://tumbledry.org/
更新 发现了这个方法:
window.location.href = window.location.href + '#abc';