我正在创建一个照片库,希望能够在浏览照片时更改查询字符串和标题.
我正在寻找的行为经常出现在一些连续/无限页面的实现中,当你向下滚动时,查询字符串会不断增加页码(http://x.com?page=4)等..这在理论上应该很简单,但我希望在主流浏览器中使用安全的东西.
I found this great post, and was trying to follow the example with window.history.pushstate
, but that doesn't seem to be working for me. And I'm not sure if it is ideal because I don't really care about modifying the browser history.
I just want to be able to offer the ability to bookmark the currently viewed photo, without reloading the page every time the photo is changed.
Here is an example of infinite page that modifies query string: http://tumbledry.org/
UPDATE发现了这种方法:
window.location.href = window.location.href + '#abc';