Rumah >hujung hadapan web >tutorial js >用js自动判断浏览器分辨率的代码_基础知识

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

WBOY
WBOYasal
2016-05-16 19:20:031039semak imbas
复制代码 代码如下:

<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> 
Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn