2014-07-17 34 views
8

我有一個由兩個單獨的html頁面(或實際上這些是一個文件夾中的兩個獨立的angularjs應用程序)組成的angularjs(v 1.2.19)應用程序:如何在angularjs中禁用IE8和IE9上的#hashbang重定向

  • 的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點擊或直接在瀏覽器的頁面將被自動重定向到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]--> 

讚賞任何幫助。

+1

也許它需要在服務器端進行調整(在html5模式下重寫)。在ui-router項目中有一個FAQ條目,請參閱https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-用html5mode工作希望這會有所幫助。 –

+0

感謝您的提示。但是,我不明白,我應該怎樣重寫。最後問題歸結爲這樣一個事實,即我有一個角度應用程序,這不在index.html下。每當我嘗試在IE8/IE9瀏覽器中打開該鏈接時,鏈接都會被角度重寫,並且添加#。我應該重寫使用Apache2等的鏈接應該是什麼? –

+0

可能出現[10 $ digest())迭代的重複。中止!當使用$ locationProvider.html5Mode(true);](http://stackoverflow.com/questions/17146461/10-digest-iterations-reached-aborting-when-using-locationprovider-html5mod) –

回答

-1

嘗試禁用html5mode $locationProvider.html5Mode(false).hashPrefix('!'); 或完全刪除此字符串。