如何禁用#hashbang在IE8和IE9重定向angularjs [英] How to disable the #hashbang redirect on IE8 and IE9 in angularjs

查看:399
本文介绍了如何禁用#hashbang在IE8和IE9重定向angularjs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由两个单独的html页面的angularjs(V 1.2.19)应用程序(或实际上这些是一个文件夹中两个不同的angularjs应用程序):

I have an angularjs (v 1.2.19) application that consists of two separate html pages (or actually these are two seperate angularjs apps in one folder):


  • 的index.html

  • edit.html

我有关于IE 8和9一些知名的兼容性问题(包括不支持HTML5历史API)。
我的配置包括: $ locationProvider.html5Mode(真).hash preFIX('!');

I am having some well-known compatibility issues on IE 8 and 9 (both do not support the html5 history API). My config contains: $locationProvider.html5Mode(true).hashPrefix('!');

我没有在应用程序中的任何路由 - index.html,然后edit.html可以被看作是单独的应用程序angularjs - 有独立的angularjs初始化等

I do not have any routing in the application - index.html and edit.html can be seen as separate angularjs apps - that have separate angularjs initialization, etc.

问题如下:
每当我打开链接:的http://服务器/应用程序 HTTP://server/app/index.html 一切工作正常。

The problem looks like this: Whenever I open the link: http://server/app or http://server/app/index.html everything works fine.

每当我打开链接: HTTP://server/app/edit.html 从纳克单击或直接在浏览器页面被自动重定向到的http://服务器/#应用程序/ edit.html

Whenever I open the link: http://server/app/edit.html from ng-click or directly in the browser the page is automatically redirected to http://server/#!app/edit.html

我如何禁用hashbang重定向? Edit.html不是的index.html的一部分,因此它应该直接而没有任何的index.html重定向和散列路由被加载。

How can I disable the "hashbang" redirection? Edit.html is not a part of the index.html, so it should be loaded directly without any index.html redirection and "hash" routing.

我试过下方的code,但它会导致重定向的无限循环......

I tried the code located below, but it leads to infinite loop of redirections...

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

任何帮助AP preciated。

Any help appreciated.

推荐答案

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

Try to disable html5mode $locationProvider.html5Mode(false).hashPrefix('!'); or remove this string completely.

这篇关于如何禁用#hashbang在IE8和IE9重定向angularjs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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