用js自动判断浏览器分辨率的代码

时间:2021-05-18

复制代码 代码如下:
<SCRIPTLANGUAGE="JavaScript">
<!--
if(window.navigator.userAgent.indexOf("MSIE")>=1)
{
varIE1024="";
varIE800="";
varIE1152="";
varIEother="";
ScreenWidth(IE1024,IE800,IE1152,IEother)
}
else{
if(window.navigator.userAgent.indexOf("Firefox")>=1)
{
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;
}
//-->
</SCRIPT>

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章