0
点赞
收藏
分享

微信扫一扫

ie6 ie 8 ff 总在页脚右下角的绝对定位top div

top.js
function setH()
{    
    var main_div_w = 1010;
    var div_w = $e('top_t').offsetWidth;
    var div_h = $e('top_t').offsetHeight;
    
     //下面二行必须定义doc w3c 标准
    var win_w = document.documentElement.clientWidth ;
    var win_h = document.documentElement.clientHeight;    
    var scroll_l = document.documentElement.scrollLeft;    
    var scroll_t = document.documentElement.scrollTop;
    var body_w = document.body.offsetWidth;
    var space_w = (body_w - 1000) /2;
    
    if (space_w < 0)
    {//左右有空白时,计算空白
      space_w =0;
    }
    
    var div_t = scroll_t + win_h - div_h;
    var div_l = scroll_l + win_w - div_w;
    
    if (div_l > 1000) div_l = 1000 + space_w;
    
     $e('top_t').style.position  = 'absolute';
     $e('top_t').style.left = div_l + 'px'; 
     $e('top_t').style.top = div_t + 'px'; 
	   
    var text = ''
             + " div_t=" + div_t 
             + " div_l=" + div_l 
             + " win_w=" + win_w
             + " win_h=" + win_h
             + " scroll_l=" + scroll_l
             + " scroll_t=" + scroll_t
             + " space_w=" + space_w
             + " body_w=" + body_w
             ;
    document.title = text; 
}setH();

function $e(objId) 
{ 
  return document.getElementById(objId); 
} 

window.onresize =window.onscroll =window.onload = function () 
{
  setH();
}

举报

相关推荐

0 条评论