完全禁用Backbone.js哈希,但是将pushState保留在历史记录中吗? [英] Disable Backbone.js hashes entirely, but keep pushState in History?

查看:125
本文介绍了完全禁用Backbone.js哈希,但是将pushState保留在历史记录中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Backbone出色的路由系统,但我不想为旧版浏览器提供任何形式的哈希支持.在Backbone.History中使用pushState时是否可以完全禁用哈希?

I'd like to use Backbone's fantastic routing system, but I'd like to NOT have any form of hash support for older browsers. Is it possible to disable hashes entirely when using pushState in Backbone.History?

推荐答案

对此没有内置支持,如果对您的应用程序以使其无法在较旧的浏览器中运行很重要,则可以修改Backbone的版本.您可以在DomReady函数的开头添加以下内容:

There's no built in support for this, if it's important to your app to not work in older browsers you could probably modify your version of Backbone. You could just add something like the following at the start of your DomReady function:

if (window.history && window.history.pushState) {
     // main script
} else {
     alert("Your browser doesn't support push state and I don't want backwards compatibility");
     window.location('http://away.from.here');
}

这篇关于完全禁用Backbone.js哈希,但是将pushState保留在历史记录中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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