右下角定位--absolute与fixed

工作中考虑的两种右下角定位--两个实例,都涉及JS

XML/HTML代码
  1. <div id="aide">例子二</div>   

 

JavaScript代码
  1. function _(id){ return document.getElementById(id);}      
  2. if(navigator.userAgent.toLowerCase().indexOf("msie 6.0") != -1){      
  3. window.setInterval(   
  4. function(){      
  5. var top = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight);      
  6. var left = (document.documentElement.clientWidth > document.body.clientWidth) && (document.documentElement.clientWidth != 0) ? document.documentElement.clientWidth : document.body.clientWidth;      
  7. _('PosiFixed').style.position = "absolute";      
  8. _('PosiFixed').style.top = (top - 70) + "px";      
  9. }      
  10. , 500);      
  11. }      
  12.   
  13. //例子二      
  14. function adBox(){       
  15. var aide = document.getElementById("aide");       
  16. aide.style.top = document.documentElement.scrollTop+document.documentElement.clientHeight-225+"px";      
  17. setTimeout(function(){adBox();},100);       
  18. }      
  19. adBox();    

详情请看 demo ......完了...

Tags: 定位, web标准

« 上一篇 | 下一篇 »

发表评论

注:网址请加上 http:// 若无,报错...

评论内容 (必填):