首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

ie 怪异模式上 position fixed javascript 实现

2012-10-26 
ie 怪异模式下 position fixedjavascript 实现!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional

ie 怪异模式下 position fixed javascript 实现
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
修改的页面文档类型竟然定义成这个,我太无语了。
好多属性什么的都不对,我太郁闷了。为了实现 position fixed 效果只能写了下面的代码 - -。

var isIE=!!window.ActiveXObject;if (isIE) {document.getElementById('notice').style.position = 'absolute';tValue = 260;if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {hWindow = document.documentElement.clientHeight;}else {hWindow = document.body.clientHeight;}window.onscroll = function(){var el = document.getElementById('notice');if (document.body && document.body.scrollTop){//top=document.body.scrollTop;//left=document.body.scrollleft;if (!isNaN(document.body.scrollTop)) {//var h = hWindow + document.body.scrollTop - 210;el.style.top = (hWindow + document.body.scrollTop - tValue) +"px";}//console.log('body: '+ document.body.scrollTop);//console.log('bottom: '+ el.style.bottom);}if (document.documentElement && document.documentElement.scrollTop){//top=document.documentElement.scrollTop;//left=document.documentElement.scrollLeft;if (!isNaN(document.documentElement.scrollTop)) {el.style.top = (hWindow + document.documentElement.scrollTop - tValue) +"px";}//console.log('documentElement: '+ document.documentElement.scrollTop);}//el.style.top = (document.documentElement.scrollTop + 10)+"px";}}

热点排行