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