最近做一个效果 将鼠标移动到图片上 图片在旁边放大显示。 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 图片 浏览器
代码如下:
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 图片 浏览器
解决方案 »
- 点击到诊确认后,如何才能不需要点击确认按钮就可以提交数据
- 在函数里面声明参数是合法吗??
- 请教关于jquery mobile的问题
- ie6中onmousemove的问题
- function.apply(this,arr)中的this指的是什么?
- 最常用的document.getElementById,你真的了解吗?
- [请教]菜单收缩脚本怎么写?(急~~)
- java或jsp 中如何从数据库中取出数据写入javascript文件中??
- 有点难度,cookie里存的是父页面的句柄,但是取出来的时候却不能用了?
- 取一定長度的字符串(不是個數)
- 【求助】 实现一个js文件在几个不同的连续跳转页面上执行
- 动态改变Ext控件属性、Tooltips位置显示的问题
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";
image.setAttribute('onmouseout', "__.hideElement('"+id+"')");
我看着你这种绑定事件方式,相当蛋疼。
image是个DOM的话直接image.onmouseout = function(){
__.hideElement(id)
}
newdiv.style.right = '40px'; //距离右边框距离
newdiv.style.top = '100px'; //距离上边框距离
这个不行 加了以后 CHROME和IE都不好使了 火狐也不行
我上面不是写了原因么:posRight 跟posTop 一般是用来获取right跟top的数值进行计算的..你现在是设置样式.
right跟top才是样式规则.
哦哦。 但是IE和CHROME可以用啊。
好吧。 还是想问下 怎么根据屏幕比例获取高度和宽度 直接写百分比吗