我需要在Web瀏覽器中粘貼一個欄到客戶端視圖的底部。傳統上我會使用position:fixed;除了我需要支持我的IE 6客戶端。我已經進行了非常廣泛的攻擊,將欄粘貼到頁面底部和內容上,但是當用戶向下或向右滾動時,欄會保持固定在頁面上。如何在IE 6,7,8的頁面底部保留一個欄,或者如何強制IE重新繪製界面?
爲了解決這個問題,我使用了一個javascript事件,它使用setInterval觸發,當在IE(8)的調試工具中運行該函數時,事件觸發並更改位置頂部和位置左屬性,但頁面沒有重繪元素。代碼有效,但元素不移動,請參見下文。
只要你知道,修復了IE瀏覽器中工作的怪癖模式......如果其他IE版本都試圖用一個標準就不能正常工作。相信我,我已經嘗試過了。
P.S.這真是讓人煩惱,因爲我重複檢查了IE9的支持......得到這個元素不會隨着IE 6,7和8中的滾動條移動,而是在IE 9中移動,它仍然顯示「IE Quirks Mode」。 「而微軟表示,此版本將不會影響任何東西,...
HTML結構
<body>
<div id="j_zoom_area" style="zoom:100%;">
The Application area the the zoom is changed (by the bar) for accessibility...
</div>
<div id="j_protectorite">
<div class="j_bar">
<div class="j_plate">Zoom Controls, Help, Search, other misc controls</div>
<div class="j_plate">Copyright info, privacy policy, etc...</div>
</div>
</div>
<script type="text/javascript" language="javascript">
j_doBar();
</script>
</body>
用於酒吧的CSS是https://kscserver.com/ERP-API/Style/includes.css。 用於條形校正的特定javascript。
//This controls the scrolling of the bar
function j_FixBarSlowly(){
var nTop = 0;
var nLeft = 0;
nTop = (document.body.scrollTop + document.body.clientHeight) - 67;
nLeft = document.body.scrollLeft;
//document.title = document.body.scrollTop + '+' + document.body.clientHeight + '-67' + '=' + nTop + 'px';
document.getElementById("j_protectorite").style.Top = nTop + 'px';
document.getElementById("j_protectorite").style.Left = nLeft + 'px';
document.getElementById("j_protectorite").style.Bottom = '';
document.getElementById("j_protectorite").style.Position = 'absolute';
//Ie6,7,8 hack to force redraw
}
function j_doBar() {
//j_FixBarSlowly();
//if (setInterval != undefined) {
// setTimeout("j_doBar();",5);
//} else {
setInterval("j_FixBarSlowly();",5);
//}
}
如果你有怪癖模式瀏覽器,你可能需要添加`<!DOCTYPE HTML>`到你的頁面的頂部(如果你沒有一個DOCTYPE,這也難怪你有瀏覽器兼容性問題)。 – Spudley 2010-12-07 15:31:21
我個人最喜歡的:Un-IE6他們:http://ie6update.com/邪惡的天才! – bpeterson76 2010-12-07 16:00:46