angular / angular.js

AngularJS - HTML enhanced for web apps!
https://angularjs.org
MIT License
58.82k stars 27.51k forks source link

IE 10/11 - browser back does not work if in iframe #6264

Open romario333 opened 10 years ago

romario333 commented 10 years ago

If you put Angular application which uses ngRoute into the iframe, it does not work correctly in IE: routing seems to be working, however when you press browser back button, you are always taken to the initial route.

I see this bug on Angular 1.2.12 and IE 10 and 11.

See this simple example for reproduction: Open index.html in IE, navigate from route1 to route2 to route3, then press back and you're taken all the way back to route1. In Chrome and Firefox this issue does not exist and history behaves as expected.

As a workaround for this bug I'm disabling HTML history API support for IE by monkey-patching $sniffer like this:


if ($.browser.msie) {
    $provide.decorator('$sniffer', function($delegate) {
      $delegate.history = false;
      return $delegate;
    });
}
caitp commented 10 years ago

If you put together a unit test for this, someone (whether a core member or community member) will have an easier time providing a solution. Otherwise this seems likely to get swept under the rug as a browser bug. I do see issues similar to this on other repositories though, and it seems like people are having difficulty solving this elsewhere, too.

romario333 commented 10 years ago

It would be difficult to write a test for this.

The best I can provide at the moment is this simple example: https://github.com/romario333/angular-in-iframe-bug

Ry-Fy commented 10 years ago

@romario333 , I don't think this issue is limited to just iFrames...If you boil a situation down to its very basics and set it up in IE10 and IE11, it still misbehaves.

Take this CodePen: http://codepen.io/anon/pen/zaGwt/

I wrote it to support this SO question: http://stackoverflow.com/questions/22919707/locationchangesuccess-not-firing-on-browser-back-action-in-ie10-and-ie11

If you extract the code from the CodePen and run it locally (to avoid CodePen's use of iFrame) you still get things all screwed up.

sushant-here commented 10 years ago

I am having this exact issue but in a phonegap app that is using angular js.

romario333's code does indeed fix this issue but it would be nice if i didnt have to do this (ie angular took care if it somehow?)

anishchandwani commented 10 years ago

Thank you for reporting this issue. A bug has been opened for IE. You can track it here: https://connect.microsoft.com/IE/feedback/details/863651/ie-10-11-browser-back-does-not-work-if-in-iframe