function move(e) {
    e = e || window.event;
    var x = e.offsetX;
    var y = e.offsetY;
    x = x - document.body.scrollLeft;
    y = y - document.body.scrollTop;
    document.onmousemove = function (e) {
        e = e || window.event;
        o.style.left = (e.clientX - x) + "px";
        o.style.top = (e.clientY - y) + "px";
    };
    document.onmouseup = function () {
        document.onmousemove = null;
    };
};

解决方案 »

  1.   

    ie11中layerX和clientX是一样的,而不是layerX和offsetX一样
      

  2.   

    感谢您的回答,IE8 下没测试,但是firefox下无移动效果。IE11下可以移动了
      

  3.   

    先判断offsetX就可以同时支持ff和ie11了
        var x = e.offsetX || e.layerX;
        var y = e.offsetY || e.layerY;
      

  4.   

    都改为clientX/Y就好了吧。。layerX这种比兼容的东东少用些好
        var x = e.clientX
        var y = e.clientY
      

  5.   

    还可以问一下吗?为什么要先判断offsetX呢?