IE 9不支持$ locationProvider.html5Mode

时间:2014-03-31 14:00:28

标签: html5 angularjs internet-explorer-9

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

2 个答案:

答案 0 :(得分:11)

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

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

我知道。愚蠢的IE。它应该死于痛苦的死亡。

答案 1 :(得分:3)

$ location文档

参见" Hashband和HTML5模式"

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

你不能只是"只是"删除"#"在没有History API的浏览器中。因为当您更改网址时,浏览器会尝试强制重新加载,从而打破流程。