Yes! Thanks Nile. It helped me a lot.
Now I'm using the function in this way:
Code:
<script type="text/javascript">
var isIE = document.all ? true : false;
document.onmousemove = getMousePosition;
function getMousePosition(e) {
var _x;
var _y;
if (!isIE) {
_x = e.pageX;
_y = e.pageY;
}
if (isIE) {
_x = event.clientX + document.body.scrollLeft;
_y = event.clientY + document.body.scrollTop;
}
posX = _x;
posY = _y;
return true;
}
function enlarge(img,x,y) {
var box = document.getElementById('zoomwindow');
var im = document.getElementById('zoomimg');
box.style.display = 'block';
box.style.left = x+'px';
box.style.top = y+'px';
im.src = img;
}
function stopenlarge() {
document.getElementById('zoomwindow').style.display = 'none';
}
</script>
I put this DIV at the bottom of my code (but inside the <body>)
HTML Code:
<div id="zoomwindow"><img src="" alt="" id="zoomimg" /></div>
which has the following CSS:
HTML Code:
#zoomwindow {
width:300px;
height:225px;
padding:10px;
border:1px solid navy;
background:white;
display:none;
position:absolute;
}
And my links are something like:
HTML Code:
<a href="javascript:void(0)" onmouseover="enlarge('/products/1/5/3/B0ED95A1.jpg',posX,posY)" onmouseout="stopenlarge()">(+) Zoom in</a>
But... often the div appears blinking as hell, despite I don't move the mouse.
It usually happens if I enter the link from the top or the sides, and not so often if I enter the link from down.
How can I fix this? Perhaps the onmouseover is not the recommended event in this case? Sorry but my JS expertise if far from satisfactory...
Bookmarks