在IE6中伪造固定位置

我有一个利用底部固定位置标头的网站: http : //www.entheospartners.com/newsite/

这个设置适用于除IE6以外的所有浏览器,IE6至少不支持固定定位,所以这就是我所做的:

当IE6用户访问该页面时,我使用这段代码确定是否需要滚动:

var windowHeight = $(window).height(); var totalHeight = windowHeight - 100; // where 100 is the sum of the top nav height + footer height var contentHeight; if($('#subpage-content-small').length) { // main content div for a three column layout contentHeight = $('#subpage-content-small').height(); }; if($('#subpage-content-wide').length) { // main content div for a two column layout contentHeight = $('#subpage-content-wide').height(); }; if(contentHeight > totalHeight) { $('#container-container').css({ 'overflow-y' : "scroll", 'height' : totalHeight }); }; 

…正确计算所有内容,将滚动条放在需要的位置(向右平齐),并将它们设置到适当的高度。 问题是滚动条不会移动内容。 我不能说我以前见过这样的东西,所以我希望这里的其他人有。 提前致谢!

PS – 显然,这需要在IE6中查看以进行故障排除,我知道这对你来说和我一样痛苦。

UPDATE

在对CSS表达式进行了一些挖掘之后,基于第一个答案,我找到了一个解决方案,用于将菜单固定定位到页面顶部。 我只需要能够使用它并将其应用到页面底部。 它并不像将所有“顶部”切换到“底部”那么简单,所以我希望有人可以启发我。 这是CSS:

 #divfixed { position: absolute; top: expression(0+((e=document.documentElement.scrollTop)?e:document.body.scrollTop)+'px'); left: expression(0+((e=document.documentElement.scrollLeft)?e:document.body.scrollLeft)+'px');} 

你可以使用CSS表达式。 以下代码已从此处复制。

 fixme { /* Netscape 4, IE 4.x-5.0/Win and other lesser browsers will use this */ position: absolute; right: 20px; bottom: 10px; } body > div#fixme { /* used by Opera 5+, Netscape6+/Mozilla, Konqueror, Safari, OmniWeb 4.5+, iCab, ICEbrowser */ position: fixed; }   

经过基于CSS表达式的更多研究后,我遇到了一个有用的jQuery插件,对我来说非常有用: http : //chrisiona.com/fixedposition/

我正在使用条件来定位IE6并将页脚栏定位在绝对底部,然后应用fixedPosition插件并且它工作得很好。 我无法设想太多其他时间我会使用这个插件,但希望它能够帮助其他人。