本帖最后由 VirusFu 于 2010-05-03 16:43:31 编辑

解决方案 »

  1.   

    因为left, right, top, bottom只有设置了position才会生效
      

  2.   

    document.getElementById('d1').style.left这种写法只支持内联样式,可以这样写
    function getType(o){
    var t;
    return ((t = typeof(o)) == 'object' ? o == null && 'null' || (Object.prototype.toString.call(o)).slice(8,-1) : t).toLowerCase();
    }

    function css(o,name){
    if(this.getType(name) == 'string'){
    if(o.style[name]) return o.style[name];
    if(o.currentStyle) return o.currentStyle[name];
    if(document.defaultView) return document.defaultView.getComputedStyle(o,"")[name];
    }else if(this.getType(name) == 'object'){
    for(var i in name){
    o.style[i] = name[i];
    }
    }
    }
          alert(document.getElementById('d1'),'left')
      

  3.   

    document.getElementById('d1').style.left这种写法只支持内联样式
    也就是说必须使用style属性,才可以获取到
      

  4.   

    楼上的,必须用style属性才可以