【问题标题】:How to disable the #hashbang redirect on IE8 and IE9 in angularjs如何在angularjs中禁用IE8和IE9上的#hashbang重定向
【发布时间】:2014-09-07 23:20:15
【问题描述】:

我有一个 angularjs (v 1.2.19) 应用程序,它由两个单独的 html 页面组成(或者实际上这些是一个文件夹中的两个单独的 angularjs 应用程序):

  • index.html
  • edit.html

我在 IE 8 和 9 上遇到了一些众所周知的兼容性问题(两者都不支持 html5 历史 API)。 我的配置包含:$locationProvider.html5Mode(true).hashPrefix('!');

我在应用程序中没有任何路由 - index.html 和 edit.html 可以被视为单独的 angularjs 应用程序 - 具有单独的 angularjs 初始化等。

问题看起来像这样: 每当我打开链接时:http://server/apphttp://server/app/index.html 一切正常。

每当我打开链接:http://server/app/edit.html 从 ng-click 或直接在浏览器中打开时,页面都会自动重定向到 http://server/#!app/edit.html

如何禁用“hashbang”重定向? Edit.html 不是 index.html 的一部分,因此应该直接加载它,而不需要任何 index.html 重定向和“哈希”路由。

我尝试了下面的代码,但它导致了无限循环的重定向......

<!--[if lt IE 10]>
    <script>   
        window.location = window.location.href.replace( /#.*/, "");
    </script>
<![endif]-->

任何帮助表示赞赏。

【问题讨论】:

标签: angularjs hashbang


【解决方案1】:

尝试禁用 html5mode $locationProvider.html5Mode(false).hashPrefix('!'); 或完全删除此字符串。

【讨论】:

    猜你喜欢
    • 2014-08-04
    • 2017-07-30
    • 2017-08-30
    • 2013-04-12
    • 1970-01-01
    • 2014-03-03
    • 2013-08-07
    • 2013-07-03
    • 1970-01-01
    相关资源
    最近更新 更多