angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

Back button / hash change history tracking not working in IE7

Open b33f3r opened this issue 13 years ago • 6 comments

Works in all other browsers we've tested, but in IE7, navigating to a new route works fine, however when you hit back, you're taken completely off the site. Seems like IE7 support needs to have better hashchange detection, possibly using document.write or creating a dummy iframe to make IE7 recognize the hash change.

jQuery BBQ seems to have this working so I'm hoping it can make its way into Angular. http://benalman.com/projects/jquery-bbq-plugin/

Please see the following resources for possible solution: http://stackoverflow.com/questions/9339865/get-the-hashchange-event-to-work-in-all-browsers-including-ie7 http://weblogs.asp.net/bleroy/archive/2007/09/07/how-to-build-a-cross-browser-history-management-system.aspx

b33f3r avatar Feb 17 '13 20:02 b33f3r

Confirmed here as well. Back button does not work in ie7. Tried with both angular 1.0.4 and 1.0.5

Here's my index.html, modified from angular seed in case this helps:

Screen Shot 2013-02-24 at 12 11 43 PM

setvik avatar Feb 24 '13 20:02 setvik

Looks like this is an old, known issue. +1 on prioritizing it as IE 7 is still heavily used in enterprise envs. Will take a look at the jQuery BBQ plugin as an alternative.

roytruelove avatar Feb 28 '13 16:02 roytruelove

Same here. It didn't work for me either. As a matter of fact, I've just tried to open Phone cat application directly from the tutorial site http://angular.github.io/angular-phonecat/step-11/app/#/phones, and navigated through the pages on IE7 and the only page that I can see is a blank page.

I also thought deep-linking on IE7 was a native issue, but jQuery history works fine. http://balupton.github.io/jquery-history/demo/#/apricots

I really think Angular has a great potential and would love to use it in my next projects, however most of my clients are running on IE7 and it'd be a long shot for me to request them to upgrade to IE8.

Thanks for the AngularJS folks for this amazing framework!

Great job, Diego

dzuluaga avatar May 16 '13 18:05 dzuluaga

I checked through sniffer.js, location.js and browser.js to check the mechanics of how history is working. In essence if the browser supports history (i.e. $sniffer.history is true) then history api is used, else it simply writes to location.href (or locaiton.replace(url)). Check $browser.url(url, replace) in browser.js, line 149.

So, if angular is just writing to location then a jquery plugin like Ben Alman's BBQ will pick up this event because it is polling for changes to location.hash. I have successfully got this working in IE8 (in IE7 mode) by simply including Ben's hashchange plugin (a subset of BBQ) and then a minimal event fire and event listening:

$(function () {
    $(window).hashchange(function() {
        // don't delete this empty handler or ie6/7 history won't work.
    });
    // call hashchange on first load
    $(window).hashchange();
});

NOTE: jQuery hashchange (and BBQ) is using deprecated $.browser.msie at line 300 so instead use (document.documentMode != undefined) as suggested in the comments to Ben's blog post.

scottywakefield avatar Jun 20 '13 09:06 scottywakefield

As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months.

Please try the newest versions of Angular (1.0.8 and 1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.

Thanks!

btford avatar Aug 24 '13 00:08 btford

Issue still persists :( :-1:

dsathyakumar avatar Oct 23 '13 13:10 dsathyakumar