1

在我的单页主干应用程序中,我无法让较长的网址在 IE 中正确路由。任何嵌套多于一层的 url 在直接加载它们时都不会收到正确的 hash fallbak。

顶级网址工作正常...

when I load: domain.com/resource
in IE I get: domain.com/#resource (as expected)

导航(应用内)工作正常......

when I click on a link to: domain.com/resource/12345
IE sends me to: domain.com/#resource/12345 (as expected)

但是访问更深的 url 会直接破坏页面

when I load: domain.com/resource/12345
in IE I get: domain.com/resource/12345 !! this is incorrect, and the page doesn't load

更新:

这是IE9

4

2 回答 2

0

我不确定您是否在过去 3 小时内更改了您的分期,但我观察到的问题与此问题有关

IE 在引用 CSS 文件时不支持基本元素中的相对路径

当您的页面请求http://stage.change4cancer.org/profile/647955793时,它会获取页面的实际 html。现在它是否应该重定向到#profile/647955793 是另一回事(为什么在你已经加载内容之后要这样做,我不确定),但让我解释一下。

在来自http://stage.change4cancer.org/profile/647955793的html 中,您有以下标签:

<base href="/" />

但 IE9 不会尊重该标签,除非它具有完整的 URI。因此,所有到 JS、CSS 等的路径都是错误的。代替

http://stage.change4cancer.org/js/libs/backbone-0.9.2.min.js

它在请求

http://stage.change4cancer.org/profile/js/libs/backbone-0.9.2.min.js

它实际上返回了另一个 html 页面

由于您的任何外部 JS 都没有加载,因此当然会出错。

于 2013-01-23T02:43:33.987 回答
0

试试这个:

Backbone.history.start({ pushState: Modernizr.history, silent: true });
if(!Modernizr.history) {
    var rootLength = Backbone.history.options.root.length;
    var fragment = window.location.pathname.substr(rootLength);
    var search = window.location.search;
    Backbone.history.navigate('/#' + fragment + search, { trigger: true });
} else {
    Backbone.history.loadUrl(Backbone.history.getFragment())
}
于 2013-01-29T17:15:18.447 回答