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


复制代码 代码如下:

<SCRIPT LANGUAGE="JavaScript">
<!--
if (window.navigator.userAgent.indexOf("MSIE")>=1)
{
var IE1024="";
var IE800="";
var IE1152="";
var IEother="";
ScreenWidth(IE1024,IE800,IE1152,IEother)
}
else{
if (window.navigator.userAgent.indexOf("Firefox")>=1)
{
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>



相关阅读:
Spring框架调用存储过程是如何实现的
Linux环境变量的设置
ASP.NET MVC TempData机制分析
javascript下计数器每秒自动加1
SQLServer 2008中SQL增强之三 Merge(在一条语句中使用Insert,Update,Delete)
random()方法和pow()方法
用VMware GSX和W2K 群集服务实现Exchange群集
js 弹出菜单/窗口效果
制作网页的5条非常不错的建议
Oracle的sql语句练习题含答案(二
PHP与SQL注入攻击[三]
CSS标示导航条当前所在频道
Linux终端图形库 Curses简介和实例分析
教你解决Windows 7操作系统中软件乱码问题
快速导航

Copyright © 2016 phpStudy |