// IE浏览器判断(IE6 - IE10)
var isIE = document.all &&document.compatMode;
// IE8判断
var isIE8 = document.all && document.querySelector && !document.addEventListener;
IE8+开始支持document.querySelector()和ducument.querySelectorAll()方法,IE9+开始支持document.addEventListener();
- CSS “\0” && “\9” hack
看到网上很多资料说”\0”是仅对IE8 有效的hack,在新版本的IE浏览器测试了各版本的表现:
浏览器\hack | \0 | \9 |
---|---|---|
IE8 | 支持 | 支持 |
IE9 | 支持 | 支持 |
IE10 | 支持 | 支持 |
IE Edge | 支持 | 不支持 |
IE8 不支持background-size属性,解决该问题的hack如下:
- github background-size pollyfill;
- AlphaImageLoader Filter @microsoft
- 其实更好的解决方法是使用img标签代替background-image属性;
IE8 不支持html5的video标签;
IE10+开始支持CSS3的transform属性,IE9不支持(edge中模拟IE9支持,但是虚拟机环境下并不支持);
IOS在进入页面后进行屏幕旋转,不支持@media (orientation:portrait/landscape) {};Media Queries: orientation兼容性见下表,而IOS6.1+已经开始支持Media Queries:orientation属性;
IE9使用-ms-transform可以支持translate属性,不支持animation;
- IE8不支持background-size的hack:
参考文献:
[1]. http://browserhacks.com/
[2]. https://github.com/louisremi/background-size-polyfill
[3]. https://stackoverflow.com/questions/2991623/how-do-i-make-background-size-work-in-ie
[4] https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms532969(v=vs.85)
[5] https://github.com/louisremi/background-size-polyfill