【问题标题】:IE 9 not supporting $locationProvider.html5ModeIE 9 不支持 $locationProvider.html5Mode
【发布时间】:2014-05-10 21:52:43
【问题描述】:

您好,我正在创建一个 angularjs 应用程序。我将 $locationProvider.html5Mode 设为 true。现在我在没有 # 的情况下得到了漂亮的 url。它在 chrome 和 firefox 中运行良好。但是当我尝试在 IE 9 中打开它时,它会不断地重新加载。

【问题讨论】:

标签: html angularjs internet-explorer-9


【解决方案1】:

坏消息。 IE9 不支持 HTML5 History API。这就是 angular html5Mode 使用的。如果您需要在 IE9 上运行您的应用程序,您需要切换回或添加代码以检测 History API 是否可用,使用是或默认为哈希

function supports_history_api() {
  return !!(window.history && history.pushState);
}

我知道。愚蠢的IE。它应该死得很痛苦。

【讨论】:

  • 嗨,现在它通过设置这个条件适用于 IE9。但是这个条件在android浏览器中返回true并且存在老问题。
  • 安卓版本是什么?
  • 我的版本是android 2.3
【解决方案2】:

$location 文档

参见“Hashband 和 HTML5 模式”

基本上,html5模式在浏览器支持时使用History API,在不支持时回退到hashbang(#)。

您不能在没有 History API 的浏览器中“仅仅”删除“#”。因为当您更改 url 时,浏览器会尝试强制重新加载,从而中断流程。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-08
    • 1970-01-01
    • 2012-06-09
    • 2015-02-23
    • 1970-01-01
    • 2013-09-06
    • 2011-10-17
    • 1970-01-01
    相关资源
    最近更新 更多