0

I'd love to use History.js for its ability to handle history (pushState etc.) in older browsers but I'd need to disable the default behavior that automatically converts hashes into a "normal" url path. By that I mean that by default the script changes link#hash to link/hash. It is great that if a push a state of "otherlink", it gives older browsers the #otherlink hash so it can still be handled but I need it to NOT automatically change link#hash to link/hash when the page is loaded. History.js seems to include an auto-initialize code so I don't even know how to load it with customized options.

To be specific, what I need is:

  • A page link#hash will remain link#hash
  • History.pushState (..., "#hash") will push the state but the page will be page#hash not page/hash
  • History.pushState (..., "hash") will be page/hash in modern browsers but page#hash in older browsers (and the script will handle what needs to be handled to load proper content).

I hope it makes sense. If it doesn't I can provide more information. Thanks for help.

4

1 回答 1

1

https://stackoverflow.com/a/21673425/2903169

引用我今天早些时候给出的上一个答案(在 history.js 中保留哈希似乎是一个流行的问题)

在 History.js github 存储库中,您可以将选项设置为强制标签为默认值

History.js Github 自述文件,选项链接

History.options.html4Mode 如果为真,将强制 HTMl4 模式(主题标签)

于 2014-02-10T09:52:19.563 回答