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

1

7

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.

Assignor answered 17/7, 2014 at 7:38 Comment(4)
Maybe it needs to be tweaked on server side (rewriting in html5 mode). There is a FAQ entry about that in ui-router project, see github.com/angular-ui/ui-router/wiki/… Hope this helps.Cremator
Thanks for the hint. I do not get, however, what should I rewrite to what. In the end the problem boils down to the fact, that I've got an angular app, that's not under index.html. Whenever I try to open that link in the IE8/IE9 browser the links get rewritten by angular and the # is added. What should be the link that I should rewrite to using Apache2, etc?Assignor
possible duplicate of 10 $digest() iterations reached. Aborting! when using $locationProvider.html5Mode(true);Budwig
How about making a directive that makes sure the full window redirect will happen? It could be an attribute you add to an <a> tag that watches for clicks and forces the window.location to this.href?Torbart
O
-1

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

Odometer answered 20/1, 2015 at 21:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.