用js自動判斷瀏覽器分辨率的代碼
更新時間:2007年01月28日 00:00:00 作者:
復(fù)制代碼 代碼如下:
<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>
相關(guān)文章
javascript學(xué)習(xí)筆記(四)function函數(shù)部分
本文主要介紹了函數(shù)的調(diào)用方式、返回函數(shù)的函數(shù)、創(chuàng)建匿名函數(shù)、javascript創(chuàng)建動態(tài)函數(shù)、回調(diào)函數(shù)、方法和函數(shù)的區(qū)別、js全局函數(shù)、函數(shù)的幾個作用、prototype屬性、高階函數(shù),非常實用,有需要的參考下2014-09-09JavaScript DOM學(xué)習(xí)第六章 表單實例
在這一章我有一個檢查用戶輸入然后打印用戶輸入的表單和代碼。下面我會著重講解檢測文本的代碼。2010-02-02JavaScript開發(fā)規(guī)范要求(規(guī)范化代碼)
作為一名開發(fā)人員(WEB前端JavaScript開發(fā)),不規(guī)范的開發(fā)不僅使日后代碼維護變的困難,同時也不利于團隊的合作,通常還會帶來代碼安全以及執(zhí)行效率上的問題。2010-08-08