JS判断显示器分辨率,调用对应CSS/JS代码
viewplainprint?
if(window.navigator.userAgent.indexOf("MSIE")>=1)
{
varIE1024="";
varIE800="";
varIE1920="";
varIEother="";
ScreenWidth(IE1024,IE800,IE1152,IEother)
}else{
if(window.navigator.userAgent.indexOf("Firefox")>=1)
{
//如果浏览器为Firefox
varFirefox1024="";
varFirefox800="";
varFirefox1152="";
varFirefoxother="";
ScreenWidth(Firefox1024,Firefox800,Firefox1152,Firefoxother)
}else{
//如果浏览器为其他
varOther1024="";
varOther800="";
varOther1152="";
varOtherother="";
ScreenWidth(Other1024,Other800,Other1152,Otherother)
}
}
functionScreenWidth(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);
}}}
}
functionsetActiveStyleSheet(title){
document.getElementsByTagName("link")[0].href="style/"+title;
}
if((screen.width<1024)&&(screen.height<768))
{
document.write("<linkrel='stylesheet'type='text/css'href='template/sunflower/styles_only.css'/>")
}
else
{
document.write("<linkrel='stylesheet'type='text/css'href='template/sunflower/styles_tri.css'/>")
}