<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
修改的页面文档类型竟然定义成这个,我太无语了。
好多属性什么的都不对,我太郁闷了。为了实现 position fixed 效果只能写了下面的代码 - -。
修改的页面文档类型竟然定义成这个,我太无语了。
好多属性什么的都不对,我太郁闷了。为了实现 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";
}
}
本文提供了一种在Internet Explorer浏览器中实现position fixed效果的方法。通过检测浏览器类型并使用绝对定位来模拟fixed行为,确保页面元素在滚动时能够固定在视口中的特定位置。
94

被折叠的 条评论
为什么被折叠?



