阻止 History.js 更改地址 URL [英] Stop History.js from changing the address URL

查看:40
本文介绍了阻止 History.js 更改地址 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在试验 History.js (https://github.com/browserstate/history.js/).我注意到当您使用 History.pushState() 时,History.js 删除了第一个/之前的所有内容,并将其替换为哈希值.

I.E.当前网址:www.google.com/something

History.pushState({},null,"something2");

将地址栏设置为 www.google.com/something2

而在 HTML4 中,它将使用哈希 (#) -> www.google.com/something#something2

无论如何要禁用此功能.我希望它不会删除/"之前的所有内容,但不必返回到 HTML4.我知道有一个 History.options.html4Mode,但我仍然喜欢它在内部存储索引的方式,而不是使用 suid.

解决方案

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

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

<块引用>

History.options.html4Mode

如果为真,将强制使用 HTMl4 模式(hashtags)

I've been experimenting with History.js lately (https://github.com/browserstate/history.js/). I notice when you use the History.pushState(), History.js removes everything upto the first / and replaces that with the hash.

I.E. current url: www.google.com/something

History.pushState({},null,"something2");

sets the address bar to www.google.com/something2

whereas in HTML4 it would use the hash (#) -> www.google.com/something#something2

Is there anyway to disable this feature. I'l like it to not remove everything up to the '/', but without necessarily going back to HTML4. I know there's a History.options.html4Mode, but I still like how it stores the index internally, as opposed to using the suid.

解决方案

Within the History.js github repo, you can set the options to force hashtags as Default

History.js Github Readme, Options Link

History.options.html4Mode  

If true, will force HTMl4 mode (hashtags)

这篇关于阻止 History.js 更改地址 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆