media screen and兼容IE8及以下浏览器css JS代码

2020-05-31 22:59:00 media ie8兼容方法JS代码实现IE8以下版本浏览器兼容media screen and判断CSS

代码如下:

 

<!--[if lte IE 8]>
<script>
!function(j,i){var k,p=function(e,d,f){e.attachEvent?(e["e"+d+f]=f,e[d+f]=function()
{e["e"+d+f](window.event)},e.attachEvent("on"+d,e[d+f])):e.addEventListener(d,f,!1)},
o=function(r,q){var t,s,x=/\s+/,w=(q||"").split(x),v=" "+r.className+" ",u=r.className;for(t=0,s=w.length;s>t;t++)
{v.indexOf(" "+w[t]+" ")<0&&(u+=" "+w[t])}r.className=u.replace(/^\s+|\s+$/g,"")},
n=function(r,q){var t,s,x=/\s+/,w=/[\n\t]/g,v=(q||"").split(x),u=(" "+r.className+" ").replace(w," ");
for(t=0,s=v.length;s>t;t++){u=u.replace(" "+v[t]+" "," ")}r.className=u.replace(/^\s+|\s+$/g,"")},
m=i.body,l=function()
{var a;a=j.innerWidth?j.innerWidth:0!==i.documentElement.clientWidth?i.documentElement.clientWidth:i.body.clientWidth,
a>1200?(n(m,"page-screen980"),o(m,"page-screen1200")):(n(m,"page-screen1200"),
o(m,"page-screen980"))};
p(window,"resize",function(){clearTimeout(k),
k=setTimeout(function(){l()},100)}),l()}(window,document);;
</script>
<![endif]-->

 

 

更新