<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title> Test Property </title>
  <meta name="generator" content="editplus" />
 </head> <body>
  <script type="text/javascript">
  <!--

var isIE = (document.all) ? true : false; var isIE6 = isIE && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6); var $ = function(sId){
return "string" == typeof(sId) ? document.getElementById(sId) : sId;
} var Bind = function(object, fun){
return function() {
return fun.apply(object, arguments);
}
} function addEventHandler(oTarget, sEventType, fnHandler){
if(oTarget.addEventListener){
oTarget.addEventListener(sEventType, fnHandler, false);
}else if(oTarget.attachEvent){
oTarget.attachEvent("on" + sEventType, fnHandler);
}else{
oTarget["on" + sEventType] = fnHandler;
}
 }  var isSafa = (window.openDatabase) ? true : false;  var TestProper = function(){

 };  TestProper.prototype = {
 // 创建广告
 CreateBanner: function(){
document.write("<div id='crazy_bannerleft' style='width:90px;border:2px solid red;height:240px;z-index:12299;onMouseDown='return false;'></div>");
document.write("<div id='crazy_bannerright' style='width:90px;height:240px;border:2px solid red;z-index:12299;onMouseDown='return false;'></div>");
this.LeftBanner = $("crazy_bannerleft");
this.RightBanner = $("crazy_bannerright");
 },  // 设置条幅的滚动程序
 SetBannerFixed: function(){
$("crazy_bannerright").style.top = (d.scrollTop+d.clientHeight-$("crazy_bannerright").offsetHeight)+"px"; 
$("crazy_bannerright").style.left = (d.scrollLeft+d.clientWidth-$("crazy_bannerright").offsetWidth)+"px"; 
$("crazy_bannerleft").style.top = (d.scrollTop+d.clientHeight-$("crazy_bannerleft").offsetHeight)+"px"; 
$("crazy_bannerleft").style.left = (d.scrollLeft)+"px"; 
 },  Init: function(){
// Safari不进行操作
if(!!isSafa)  return;
var $d = document.compatMode == "BackCompat" ? d = document.body : d = document.documentElement;
this.CreateBanner();
this.LeftBanner.style.position =  !isIE6 ? "fixed" : "absolute";
this.RightBanner.style.position = !isIE6 ? "fixed" : "absolute";
if(isIE6) {
addEventHandler(window, "scroll", this.SetBannerFixed);
}
addEventHandler(window, "load", this.SetBannerFixed);
addEventHandler(window, "resize", this.SetBannerFixed);
 } 
 }  var Test = new TestProper();
 Test.Init();
  //-->
  </script>
   <br/><br/><br/><br/><br/><br/><br/><br/>
  <br/><br/><br/><br/><br/><br/><br/><br/>
  <br/><br/><br/><br/><br/><br/><br/><br/>
  <br/><br/><br/><br/><br/><br/><br/><br/>
  <br/><br/><br/><br/><br/><br/><br/><br/>
  <br/><br/><br/><br/><br/><br/><br/><br/>
  <br/><br/><br/><br/><br/><br/><br/><br/>
  <br/><br/><br/><br/><br/><br/><br/><br/>
  <br/><br/><br/><br/><br/><br/><br/><br/>
  <br/><br/><br/><br/><br/><br/><br/><br/>
  <br/><br/><br/><br/><br/><br/><br/><br/>
  <br/><br/><br/><br/><br/><br/><br/><br/>
 </body>
</html>要求很简单,就是让两个DIV一直浮动在页面左右的最底端。
现在的代码在IE6和Chrome浏览器下测试没问题  但在FF下测试有问题,就是在页面resize的时候 DIV会消失请朋友们指点下。有时间的 再看下
http://topic.csdn.net/u/20090505/16/f63f9830-a4b6-4ab5-ba41-ba70fcdb471b.html?seed=630934394&t=fudgtzhb

解决方案 »

  1.   

    CSDN的斑竹们,戴大红花 小绿花的高手们你们如果在线的话,好歹也支持下吧。
    或者说 你这问题太简单 我不惜得解决 或者说 这问题太难没法解决那样我好死心啊
      

  2.   


    没有出现你说问题啊,IE、FF都是停在页面的底部,我的FF是3.0.9的
      

  3.   


    楼上的兄弟 ,估计我说漏了
    你用火狐 打开后 拖动滚动条 然后再Resize 看看
      

  4.   

    实现居中 右底的效果不难  看你的代码不爽啊.还要在你的效果上修改
    右底的....  ie  ff没问题  没有Chrome
    <body><div id="ss" style="height:200px; width:200px; background-color:#FF0000; position:absolute"></div>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></body>
    <script>
    var div = document.getElementById("ss")
    var top = document.body.clientHeight-div.offsetHeight
    function change()
    {  
       div.style.left=document.body.clientWidth-div.offsetWidth //左底=0
       div.style.top =document.body.clientHeight-div.offsetHeight+document.body.scrollTop
       top = document.body.clientHeight-div.offsetHeight
    }
    change()
    window.onresize=change
    window.onscroll=function(){div.style.top=top+document.body.scrollTop}
    </script>
    </html>
    居中的
    <body><div id="ss" style="height:200px; width:200px; background-color:#FF0000; position:absolute"></div>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></body>
    <script>
    var div  = document.getElementById("ss")
    var top  = (document.body.clientHeight-div.offsetHeight)/2
    var left = (document.body.clientWidth-div.offsetWidth)/2
    function change()
    {  
       div.style.left=(document.body.clientWidth-div.offsetWidth)/2
       div.style.top =(document.body.clientHeight-div.offsetHeight)/2+document.body.scrollTop
       top = (document.body.clientHeight-div.offsetHeight)/2
       left = (document.body.clientWidth-div.offsetWidth)/2
    }
    change()
    window.onresize=change
    window.onscroll=function(){div.style.top=top+document.body.scrollTop}
    </script>
      

  5.   

             Init: function(){
                // Safari不进行操作
                if(!!isSafa)  return;
                var $d = document.compatMode == "BackCompat" ? d = document.body : d = document.documentElement;
                this.CreateBanner();
                this.LeftBanner.style.position =  !isIE6 ? "fixed" : "absolute";
                this.RightBanner.style.position = !isIE6 ? "fixed" : "absolute";
                if(isIE6) {
                    addEventHandler(window, "scroll", this.SetBannerFixed);
                }
                //addEventHandler(window, "load", this.SetBannerFixed);
                //addEventHandler(window, "resize", this.SetBannerFixed);
    $("crazy_bannerright").style.bottom = 0; 
                    $("crazy_bannerright").style.right = 0; 
                    $("crazy_bannerleft").style.bottom = 0; 
                    $("crazy_bannerleft").style.left = 0; 
             } 
    看来你还没明白fixed的作用啊
      

  6.   

    cloudgamer 现在我的问题是 左右两个DIV 不一定 都是在最下边的我想实现 TOP值可以自己调节  那样IE6下 滚动时应该怎么计算 比如 我让左DIV 的TOP值为60px
      

  7.   

    wtcsy 
    嗯 左下 简单的  我主要是试了下fixed的用法你帮我看下7楼的要求
      

  8.   

    但你问的不是ff吗
    怎么变成ie6了
      

  9.   

    哈哈,我也都被他问晕了
    之前他还说的是FF好的,IE6有问题到这里也一会FF一会IE6的
      

  10.   


    cloudgamer 不好意思 刚才你改完后 我知道问题所在了。。
    刚才问的IE6问题 我自己解决了。主要现在要兼容所有浏览器 ,所以 上一个贴子的问题 还有小毛病 
      

  11.   

    呵呵,就单单这个帖子你看你说的
    一会FF一会IE6的能不晕吗?
      

  12.   

    cloudgamer就这个地方 问你个问题 关于Bindthis._bannerfixed = Bind(this, function(){this.SetBannerFixed();})
    // 如果 我想调用this._bannerfixed(obj)并且 想传个object对象 给SetBannerFixed()应该怎么去写
      

  13.   

    var Bind = function(object, fun) {
    var args = Array.prototype.slice.call(arguments).slice(2);
    return function() {
    return fun.apply(object, args.concat(Array.prototype.slice.call(arguments)));
    }
    }用这个bind就可以了
      

  14.   


    var Bind = function(object, fun) {
        var args = Array.prototype.slice.call(arguments).slice(2);
        return function() {
            return fun.apply(object, args.concat(Array.prototype.slice.call(arguments)));
        }
    }SetFixed: function(obj){
    alert(obj)

    }this._fixed = Bind(this, function(){this.isCenter ? this.SetCenter() : this.SetFixed();})this._fixed(Object);
    这样用么?
      

  15.   

    但是我传了之后
    this._fixed = Bind(this, function(){this.isCenter ? this.SetCenter() : this.SetFixed();})this.isMaxFixed && addEventHandler(window, "scroll", this._fixed("dddd"));SetFixed: function(obj){
        alert(obj)
        
    }打印的是undefined
      

  16.   

    this._fixed = Bind(this, function(x){this.isCenter ? this.SetCenter() : this.SetFixed(x);}) 
    你要把参数传进去嘛
      

  17.   

    哦 刚才写漏了发现问题所在了this.isMaxFixed && addEventHandler(window, "scroll", this._fixed("dddd")); 
    //this._fixed("dddd")这样是不可以的 因为addEventHandler只能传句柄this._fixed
    是不是应该怎样 弄个闭包解决?
      

  18.   

    哦了 自己解决了
    if(isIE6) {
    this.isMaxFixed && addEventHandler(window, "scroll", (function(obj){
    return function(){
    oThis._fixed(obj);
    }
    })(this.Container));
    }也真繁琐
      

  19.   

    this.isMaxFixed && addEventHandler(window, "scroll", Bind(this,this._fixed,"dddd"));
    这样应该也可以