首頁 > web前端 > js教程 > 用js自动判断浏览器分辨率的代码_基础知识

用js自动判断浏览器分辨率的代码_基础知识

WBOY
發布: 2016-05-16 19:20:03
原創
1029 人瀏覽過
复制代码 代码如下:

<script> <BR><!-- <BR>if (window.navigator.userAgent.indexOf("MSIE")>=1) <BR>{ <BR>var IE1024=""; <BR>var IE800=""; <BR>var IE1152=""; <BR>var IEother=""; <BR>ScreenWidth(IE1024,IE800,IE1152,IEother) <BR>} <BR>else{ <BR>if (window.navigator.userAgent.indexOf("Firefox")>=1) <BR>{ <BR>var Firefox1024=""; <BR>var Firefox800=""; <BR>var Firefox1152=""; <BR>var Firefoxother=""; <BR>ScreenWidth(Firefox1024,Firefox800,Firefox1152,Firefoxother) <BR>} <BR>else{ <BR>var Other1024=""; <BR>var Other800=""; <BR>var Other1152=""; <BR>var Otherother=""; <BR>ScreenWidth(Other1024,Other800,Other1152,Otherother) <BR>} <BR>} <BR>function ScreenWidth(CSS1,CSS2,CSS3,CSS4){ <BR>if ((screen.width == 1024) && (screen.height == 768)){ <BR>setActiveStyleSheet(CSS1); <BR>}else{ <BR>if ((screen.width == 800) && (screen.height == 600)){ <BR>setActiveStyleSheet(CSS2); <BR>}else{ <BR>if ((screen.width == 1152) && (screen.height == 864)){ <BR>setActiveStyleSheet(CSS3); <BR>}else{ <BR>setActiveStyleSheet(CSS4); <BR>}}} <BR>} <BR>function setActiveStyleSheet(title){ <BR>document.getElementsByTagName("link")[0].href="style/"+title; <BR>} <BR>//--> <BR></script> 
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板