I am using this script to display an image as popup on mouseover. The difficulty I am facing is that it is not positioning well in different monitor. It must be something to do with resolution.
function LargeImage(obj, e)
{
var imgbtn=document.getElementById('<%=imgbtn1.ClientID%>');
imgbtn.src=obj;//source of the image
document.getElementById('imgbox').style.visibility="visible";
document.getElementById('imgbox').style.position="absolute";
document.getElementById('imgbox').style.left=e.clientX-150 + "px";
document.getElementById('imgbox').style.top=225 +"px";
}
<div id="imgbox"><asp:imagebutton id="imgbtn1" runat="server" OnClick="ImageButton4_Click"/></div>
Thank you.
you can do this
which will show the picture at the mouse location in the window (popup stays put if the user scrolls).
otherwise you need to compensate for document scrolling, something like
edit: fix the scroll value (for firefox)
you can look here to find a demo of determining which property to read for scrolling offsets by browser
http://www.howtocreate.co.uk/tutorials/javascript/browserwindow