您的位置:首页 > 运维架构

兼容各浏览器的clientWidth,clientHeight,scrollWidth,scrollHeight,scrollLeft,scrollTop

2012-01-04 18:57 609 查看
var cWidth, cHeight, sWidth, sHeight, sLeft, sTop;
		if (document.compatMode == "BackCompat") 
		{
			cWidth = document.body.clientWidth;
			cHeight = document.body.clientHeight;
			sWidth = document.body.scrollWidth;
			sHeight = document.body.scrollHeight;
			sLeft = document.body.scrollLeft;
			sTop = document.body.scrollTop;
		} 
		else // document.compatMode == "CSS1Compat"
		{
			cWidth = document.documentElement.clientWidth;
			cHeight = document.documentElement.clientHeight;
			sWidth = document.documentElement.scrollWidth;
			sHeight = document.documentElement.scrollHeight;
			sLeft = document.documentElement.scrollLeft == 0 ? document.body.scrollLeft
					: document.documentElement.scrollLeft;
			sTop = document.documentElement.scrollTop == 0 ? document.body.scrollTop
					: document.documentElement.scrollTop;
		}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐