国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > JS > 正文

根據分辨率不同,調用不同的css文件

2024-09-06 12:45:12
字體:
來源:轉載
供稿:網友

dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellSpacing=0 cellPadding=6 width="95%" align=center border=0>  <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)
{
file://如果瀏覽器為Firefox
var Firefox1024="";
var Firefox800="";
var Firefox1152="";
var Firefoxother="";
ScreenWidth(Firefox1024,Firefox800,Firefox1152,Firefoxother)
}else{
file://如果瀏覽器為其他
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; 
}
file://-->
</SCRIPT>

 


解釋:

 

var IE1024="";
var IE800="";
var IE1152="";
var IEother="";


引號里面分別填寫,用戶使用IE的時候并且分辨率為1024*768,800*600,1152*864要使用的css文件名.

 

var Firefox1024="";
var Firefox800="";
var Firefox1152="";
var Firefoxother="";


引號里面分別填寫,用戶使用FF的時候并且分辨率為1024*768,800*600,1152*864要使用的css文件名.

 

var Other1024="";
var Other800="";
var Other1152="";
var Otherother="";


引號里面分別填寫,用戶使用其他瀏覽器的時候并且分辨率為1024*768,800*600,1152*864要使用的css文件名.

不判斷分辨率,只判斷瀏覽器

應E.Qiang提議,編如下代碼。實現根據瀏覽器類型自動調用不同CSS。

代碼:


<SCRIPT LANGUAGE="javascript">
<!--
if (window.navigator.userAgent.indexOf("MSIE")>=1)
{
file://如果瀏覽器為IE
setActiveStyleSheet("default.css");
}else{
if (window.navigator.userAgent.indexOf("Firefox")>=1)
{
file://如果瀏覽器為Firefox
setActiveStyleSheet("default2.css");
}else{
file://如果瀏覽器為其他
setActiveStyleSheet("newsky.css");
}

function setActiveStyleSheet(title){ 
document.getElementsByTagName("link")[0].href="style/"+title; 
}
file://-->
</SCRIPT>

解釋:

如果瀏覽器為IE,則調用default.css

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 正蓝旗| 宿州市| 通道| 防城港市| 西宁市| 南涧| 辛集市| 云龙县| 滨海县| 巩义市| 洛隆县| 唐河县| 五常市| 南川市| 鸡泽县| 西畴县| 慈溪市| 安多县| 镇赉县| 平顶山市| 正蓝旗| 长阳| 石景山区| 滨海县| 临猗县| 长子县| 香河县| 兴隆县| 西盟| 西平县| 宝应县| 鲁甸县| 临清市| 平遥县| 泗水县| 弥勒县| 乌苏市| 社会| 平顺县| 靖远县| 澜沧|