How to disable the #hashbang redirect on IE8 and IE9 in angularjs

感情迁移 提交于 2019-12-21 04:17:07

问题


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

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('!');

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.

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

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

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.

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]-->

Any help appreciated.


回答1:


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



来源:https://stackoverflow.com/questions/24797570/how-to-disable-the-hashbang-redirect-on-ie8-and-ie9-in-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!