I am using routing in Angularjs
for my SPA but I have to support IE7 (and IE8 in IE7 compatibility mode). I want the browser history to still work though. I don't care if I have to use a jQuery plugin.
The continuous integration server runs all unit tests against IE9, IE10, and IE11. See CircleCI. We do not run tests on IE8 and below. A subset of the AngularJS functionality may work on these browsers, but it is up to you to test and decide whether it works for your particular app.
Angular 13 does not support Internet Explorer 11. This is a step in the right direction, as dropping IE 11 results in faster app loading times and a smaller bundle size. It also means Angular 13 is free to use modern browser features, such as web animations and CSS variables via native web APIs.
Supporting Internet Explorer in Angular is easy if you just remember where to find that polyfills. ts file. Finally, take a minute to stop by the core-js GitHub project and give it a star.
I checked through the angular source 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 out $browser.url(url, replace)
in browser.js, line 149 for details.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With