首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > 跨浏览器开发 >

如何根据浏览器类型载入不同css

2012-06-04 
怎么根据浏览器类型载入不同css?我使用了网上搜索到的几种方式,但是却发现没有一种方法是能够覆盖所有浏览

怎么根据浏览器类型载入不同css?
我使用了网上搜索到的几种方式,但是却发现没有一种方法是能够覆盖所有浏览器类型的。
//这个只对IE有效果,对chrome无效
<!--[if lte IE 7]>
  <link href="Style/IE.css" rel="stylesheet" type="text/css" />
<![endif]-->

//ie有效,chrome无效
document.createStyleSheet(cssFile);


//ie chrome都无效
varhead=document.getElementsByTagName('HEAD').item(0);
varstyle=document.createElement('link');
style.href='style.css';
style.rel='stylesheet';
style.type='text/css';
head.appendChild(style);

求指点。


[解决办法]
怎么无效了?

HTML code
<!DOCTYPE HTML><html>    <head>        <meta charset="gb2312" />        <title></title>        <style>        </style>            </head>    <body>        123        <script>            var head=document.getElementsByTagName('HEAD')[0];            var style=document.createElement('link');            style.href='http://yui.yahooapis.com/2.9.0/build/reset/reset-min.css';            style.rel='stylesheet';            style.type='text/css';            head.appendChild(style);        </script>    </body></html> 

热点排行