CompatbilityStuffs

CompatbilityStuffs

by divayang

HTML

<p>各种各样积累的小方法</p>

<!--左、右两栏分栏样式: Type 1-->
<div class="mainBox">
	<div class="mainWrap"></div>
</div>
<div class="col_left"></div>
<!--左、右两栏分栏样式: Type 2-->
<div class="panel_main">
	<div class="panel_main_wrap"><div>
</div>
<div class="panel_side">

CSS

/*  li 在所有浏览器中水平横排 */
ul{ zoom:1; white-space:nowrap; }
li{display:inline-block; *display:inline; *zoom:1;}

/*  左、右两栏分栏样式: Type 1 */
.col_left {
	float:left;
	width:160px;
	margin-left:-100%;
	*margin-left:0;	
	height:200px;
	background:#f00;
}
.mainBox {
	float:left;
	width:100%;
	*margin-right:-100%;
}
.mainBox .mainWrap { 
	margin-left: 170px;
	height:200px;
	background:#00f;
}
/*  左、右两栏分栏样式: Type 2 */
.panel_main {
	width:100%;
	float:left;
	*margin-right:-100%;
}
.panel_main .panel_main_wrap {
	margin-right:210px;
}
.panel_side {
	float:right;
	width:200px;
	margin-left:-100%;
	*margin-left:0;
}

/* ie6 iframe要遮住原生的select */
.ie6 iframe {_background-color:transparent; _filter:alpha(opacity=0);}

JavaScript

//最简单的判断IE浏览器版本:
    isIE = (function(){ 
        var v = 3, 
        div = document.createElement('div'), 
        all = div.getElementsByTagName('i'); 
        //通过IE检测HTML条件注释方式 
        //循环判断IE浏览器当前支持版本 
        while ( 
        div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', 
        all[0] 
        ); 
        return v > 4 ? v : undefined; 
    })();



//最简单的判断IE浏览器模式版本 2:

/* Reset body class for IE8+ CSS hack */
if ((navigator.appName == "Microsoft Internet Explorer") && (document.documentMode != "undefined")){
        document.getElementsByTagName("body")[0].className = "ie"+ document.documentMode;
}


//JS if ie6
!-[1, ] && !window.XMLHttpRequest && alert("IE6");

//JS if ie6、7、8
!-[1, ] && alert("IE6\7\8");

//if IE
if(!!window.ActiveXObject ){
 alert("IE");
}

//原生JS获取页面高度、宽度等信息

function GetPageSize() {
                   var scrW, scrH;
                   if(window.innerHeight && window.scrollMaxY)
                   {    // Mozilla   
                            scrW = window.innerWidth + window.scrollMaxX;   
                            scrH = window.innerHeight + window.scrollMaxY;
                   }
                   else if(document.body.scrollHeight > document.body.offsetHeight)
                   {    // all but IE Mac   
                            scrW = document.body.scrollWidth;   
                            scrH = document.body.scrollHeight;
                   } else if(document.body)
                   { // IE Mac   
                            scrW = document.body.offsetWidth;   
                            scrH = document.body.offsetHeight;
                   }
                   var winW, winH;
                   if(window.innerHeight)
                   { // all except IE   
                            winW = window.innerWidth;
                            winH = window.innerHeight;
                   } else if (document.documentElement && document.documentElement.clientHeight)
                   {    // IE...