AngularJS IE 8 Support

2019-03-29 07:07发布

I'm building a one-page website, using AngularJS, ui-router and jquery, and I need it to support ie 8 browsers.
I followed the instructions from the AngularJS documentation (link), and I also read this and followed its instructions.
In a nutshell: I added this code in the header:

<html xmlns:ng="http://angularjs.org" id="ng-app" ng-app="myApp">

and also:

<!--[if lt IE 9]>
    <script type="text/javascript" src="/app/js/3rdparty/html5shiv.js"></script>
    <script type="text/javascript" src="/app/js/3rdparty/json3.min.js"></script>
<![endif]-->

All of my directives are restricted to be used as attribute directives (no custom tags).
But still, no view is being rendered, and no directive is working (on ie8).

I started using ui-router only recently, and the problem existed even before.
I really can't find the problem, and I've searched a lot.
There are many duplicates for this, I know, but none of their solutions helped me (and most of them pretty much refer to angularjs's documentation).
I haven't posted any other code, since there's a lot of it, and I really can't figure out what part of the code (other than the index.html) can be causing any problem.
I'll post any other code if you think it might help.
I'm really lost and would really be grateful if someone could guide me to a solution.
Thank you very much

3条回答
叼着烟拽天下
2楼-- · 2019-03-29 07:49

In case if you've used any console.log() within your controller or service or factory then IE-8 won't load the angular at all. It's weird.

查看更多
做自己的国王
3楼-- · 2019-03-29 07:50

I have met the same problem recently because of the compatibility mode.

Try to force it with :

<!--[if IE 8]><!--> <meta http-equiv="X-UA-Compatible" content="IE=8" /> <!--<![endif]-->

Also check in your IE8 browser that your compatibility mode is not IE7.

查看更多
Deceive 欺骗
4楼-- · 2019-03-29 07:56

Seems I made a bit of a fool out of myself.
The problem was that I was using some reserved words, and apparently IE8 really doesn't like it at all.
For instance I had a parameter named "class" on an object, so using obj.class just made IE8 freak out.
The same with a function named "delete" (again inside an object, so I was using functionHoldingObject.delete.

I knew about reserved words, I just didn't think using them as a parameter of an object is harmful. In order to fix this, I just changed the names for some, and used obj["reservedWord"] for others, both solutions work on all browsers.

Another error I found, was that I was using the Array.prototype.indexOf function without knowing that IE8 doesn't support it. So I just added an implementation (which is very easy).
You could get help on that on the MDN site.

查看更多
登录 后发表回答