最近做一个效果  将鼠标移动到图片上  图片在旁边放大显示。  IE  CHROME等浏览器都好用。 就是FIREFOX不好使  图片不出来 (juqery easyui框架)
代码如下:
showFloatingImage:function(image) 

var id = "trailimageid"; 
var newdiv = document.getElementById(id); 
if(newdiv == null) 

newdiv = document.createElement('div');
newdiv.setAttribute('id',id);
document.body.appendChild(newdiv);
}
image.setAttribute('onmouseout', "__.hideElement('"+id+"')"); 
newdiv.innerHTML = '<img src='+image.src+ ' width='+(image.width + width) + ' height=' + (image.height + height) + ' />'; 
newdiv.style.position = "absolute";
newdiv.style.posRight = 40;   //距离右边框距离
newdiv.style.posTop = 100;    //距离上边框距离
newdiv.style.display="block";
},
hideElement:function(id) 

var elem = document.getElementById(id); 
elem.style.display="none"; 
firefox 图片 浏览器 

解决方案 »

  1.   

    改红色部分试试,事件绑定不要使用setAttribute,有些浏览器不支持
            image.onmouseout = function () { __.hideElement(id) }
            newdiv.innerHTML = '<img src=' + image.src + ' width=' + (image.width + width) + ' height=' + (image.height + height) + ' />';
            newdiv.style.position = "absolute";
            newdiv.style.posRight = '40px';   //距离右边框距离
            newdiv.style.posTop = '100px';    //距离上边框距离

            newdiv.style.display = "block";
      

  2.   

    你传入的image是个啥东西?
    image.setAttribute('onmouseout', "__.hideElement('"+id+"')");
    我看着你这种绑定事件方式,相当蛋疼。
    image是个DOM的话直接image.onmouseout = function(){
    __.hideElement(id)
    }
      

  3.   

    另外posRight 跟posTop 一般是用来获取right跟top的数值进行计算的..你设置样式直接:
    newdiv.style.right = '40px';   //距离右边框距离
    newdiv.style.top = '100px';    //距离上边框距离
      

  4.   


    这个不行  加了以后  CHROME和IE都不好使了  火狐也不行
      

  5.   


    我上面不是写了原因么:posRight 跟posTop 一般是用来获取right跟top的数值进行计算的..你现在是设置样式.
    right跟top才是样式规则.
      

  6.   


    哦哦。  但是IE和CHROME可以用啊。
      好吧。   还是想问下 怎么根据屏幕比例获取高度和宽度  直接写百分比吗