您的位置:首页 > Web前端 > CSS

根据不同浏览器使用不同的css文件

2013-06-29 14:19 369 查看
代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/IE6.css"/>
<title>无标题文档</title>
<script type="text/javascript" language="javascript">
function setCss(){
//根据浏览器来选择CSS
if (!window.XMLHttpRequest) {
setActiveStyleSheet("IE6.css"); //IE6
}else if(window.ActiveXObject){
setActiveStyleSheet("IE7.css"); //IE7, 以及IE7+
} else {
setActiveStyleSheet("other.css"); //Mozilla FireFox、Safari, etc.
}

}
function setActiveStyleSheet(filename){
var path = document.getElementsByTagName("link")[0].href;
document.getElementsByTagName("link")[0].href="css/"+filename;
alert("css/"+filename);
}
window.onload=setCss;
</script>
</head>

<body>
asdasdasd<br />
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: