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

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

WBOY
WBOYoriginal
2016-05-16 19:20:031003parcourir
复制代码 代码如下:

<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> 
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn