关闭

浏览器兼容--CSS

126人阅读 评论(0) 收藏 举报

http://www.cnblogs.com/tangzx365/archive/2011/01/18/1938149.html

 

////不同浏览器,分辨率:

<link href="" rel="stylesheet" type="text/css" />

<script  type= "text/javascript"  language="JavaScript">
<!--
if (window.navigator.userAgent.indexOf("MSIE")>=1)
{
//如果浏览器为IE
var IE1024="default.css";
var IE800="default.css";
var IE1152="default.css";
var IEother="default.css";
ScreenWidth(IE1024,IE800,IE1152,IEother)
}else{
if (window.navigator.userAgent.indexOf("Firefox")>=1)
{
//如果浏览器为Firefox
var Firefox1024="";
var Firefox800="";
var Firefox1152="";
var Firefoxother="";
ScreenWidth(Firefox1024,Firefox800,Firefox1152,Firefoxother)
}else{
//如果浏览器为其他
var Other1024="";
var Other800="";
var Other1152="";
var Otherother="";
ScreenWidth(Other1024,Other800,Other1152,Otherother)
}
}
function ScreenWidth(CSS1,CSS2,CSS3,CSS4){
if ((screen.width == 1024) && (screen.height == 768)){
setActiveStyleSheet(CSS1);
}else{
if ((screen.width == 800) && (screen.height == 600)){
setActiveStyleSheet(CSS2);
}else{
if ((screen.width == 1152) && (screen.height == 864)){
setActiveStyleSheet(CSS3);
}else{
setActiveStyleSheet(CSS4);
}}}
}
function setActiveStyleSheet(title){
document.getElementsByTagName("link")[0].href="style/"+title;

}
//-->
</script>

////不同浏览器:
<script type ="text/javascript" language="javascript" >

if (window.navigator.userAgent.indexOf("MSIE")>=1)
{
//如果浏览器为IE
document.write('<link rel=stylesheet type="text/css" href="style/default.css">')
}
else
{
if (window.navigator.userAgent.indexOf("Firefox")>=1)
{
//如果浏览器为Firefox
document.write('<link rel=stylesheet type="text/css" href="style/default2.css">')
}
else
{
//如果浏览器为其他
document.write('<link rel=stylesheet type="text/css" href="style/newsky.css">')
}
}
</script>

////不同分辨率:

 <script  type="text/javascript"  language="javascript" >

if (screen.width == 800)
{
document.write('<link rel=stylesheet type="text/css" href="style/css800.css">')
}
else {document.write('<link rel=stylesheet type="text/css" href="style/css1024.css">')}
 
</script>

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:118551次
    • 积分:1465
    • 等级:
    • 排名:千里之外
    • 原创:0篇
    • 转载:163篇
    • 译文:0篇
    • 评论:14条
    文章存档
    最新评论