Forum Moderators: open

Message Too Old, No Replies

Big picture does not show properly under chrome and firefox

he big picture should display just at right and above the small one

         

abiao

4:22 am on Jan 2, 2015 (gmt 0)

10+ Year Member



<div class="footer">
<img src="mypicture.jpg" width="40" height="40" onmouseover="ShowFloatingImage(this, 150, 150);" />
</div>

<script>

function GetAbsPosition(obj)
{
var curleft = 0, curtop = 0;
do {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
return [curleft,curtop];
}

function ShowFloatingImage(image, width, height)
{
var id = "trailimageid";
var newdiv = document.getElementById(id);
if(newdiv == null)
{
newdiv = document.createElement('div');
newdiv.setAttribute('id',id);
newdiv.setAttribute('onmouseout', "HideElement('"+id+"');");
document.body.appendChild(newdiv);
}
newdiv.innerHTML = '<img src='+image.src+ ' width='+(image.width + width) + ' height=' + (image.height + height) + ' />';

var absPos = GetAbsPosition(image);
newdiv.style.position = "absolute";
newdiv.style.posLeft = absPos[0] - width;
newdiv.style.posTop = absPos[1] - height;
newdiv.style.display="block";
}

function HideElement(id)
{
var elem = document.getElementById(id);
elem.style.display="none";
}

</script>

Fotiman

4:36 am on Jan 2, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



posLeft and posTop are IE deviations. Try using "left" and "top" instead, which should work in all browsers (though you need to include the units):

newdiv.style.left = (absPos[0] - width) + "px";
newdiv.style.top = (absPos[1] - height) + "px";

abiao

6:46 am on Jan 2, 2015 (gmt 0)

10+ Year Member



runs perfectly, many thanks.